Skip to content

Instantly share code, notes, and snippets.

@aggerdom
Created March 10, 2016 01:01
Show Gist options
  • Save aggerdom/8ff67b6b4c6717c41914 to your computer and use it in GitHub Desktop.
Save aggerdom/8ff67b6b4c6717c41914 to your computer and use it in GitHub Desktop.
Flatten nested lists of integers
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