Created
March 10, 2016 01:01
-
-
Save aggerdom/8ff67b6b4c6717c41914 to your computer and use it in GitHub Desktop.
Flatten nested lists of integers
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 flat_list(array): | |
o = [] | |
while array: | |
n = array.pop(0) | |
if type(n)==int: | |
o.append(n) | |
else: | |
for i in n[::-1]: | |
array.insert(0,i) | |
return o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment