Created
March 23, 2018 17:17
-
-
Save danielvlopes/b794840f6a1390f88eb5e17787e35ab0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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