Created
August 30, 2018 12:12
-
-
Save mertkahyaoglu/19efc9699d667a4ac139fd0b42b284bd 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:]) | |
arr = [1, [2,[3],4,5], [6],7] | |
print flatten(arr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment