Created
October 18, 2011 13:53
-
-
Save aramk/1295475 to your computer and use it in GitHub Desktop.
Expand recursive list in Python
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 expand_list(list_of_lists): | |
list = [] | |
for i in list_of_lists: | |
if type(i) is type([]): | |
i = expand_list(i) | |
for j in i: | |
list.append(j) | |
else: | |
list.append(i) | |
return list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment