Created
May 8, 2015 08:45
-
-
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].
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new_list(list1, list2): | |
list = [] | |
for item1, item2 in zip(list1, list2): | |
list.append(item1) | |
list.append(item2) | |
return list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please can you do the exact same in java