Skip to content

Instantly share code, notes, and snippets.

@pharshal
Created May 8, 2015 08:45
Show Gist options
  • Save pharshal/5d587793a9701179be98 to your computer and use it in GitHub Desktop.
Save pharshal/5d587793a9701179be98 to your computer and use it in GitHub Desktop.
Write a function that combines two lists by alternatingly taking elements. For example: given the two lists [a, b, c] and [1, 2, 3], the function should return [a, 1, b, 2, c, 3].
def new_list(list1, list2):
list = []
for item1, item2 in zip(list1, list2):
list.append(item1)
list.append(item2)
return list
@cassandraC10
Copy link

please can you do the exact same in java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment