Skip to content

Instantly share code, notes, and snippets.

@danielvlopes
Created March 23, 2018 17:17
Show Gist options
  • Select an option

  • Save danielvlopes/b794840f6a1390f88eb5e17787e35ab0 to your computer and use it in GitHub Desktop.

Select an option

Save danielvlopes/b794840f6a1390f88eb5e17787e35ab0 to your computer and use it in GitHub Desktop.
def flatten(s):
if s == []:
return s
if isinstance(s[0], list):
return flatten(s[0]) + flatten(s[1:])
return s[:1] + flatten(s[1:])
l1 = [[1,2],[3,4],[[5,6],[7,8],[[[1,3]]]]]
print flatten(l1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment