Skip to content

Instantly share code, notes, and snippets.

@dhilipsiva
Created October 9, 2017 16:57
Show Gist options
  • Save dhilipsiva/846b5b2b465ca046f3993ba2c1c8891e to your computer and use it in GitHub Desktop.
Save dhilipsiva/846b5b2b465ca046f3993ba2c1c8891e to your computer and use it in GitHub Desktop.
Flatten
def flatten(items):
new_items = []
for item in items:
if type(item) == int:
new_items.append(item)
else:
new_items += flatten(item)
return new_items
print(flatten([[1,2,[3]],4]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment