Skip to content

Instantly share code, notes, and snippets.

@mertkahyaoglu
Created August 30, 2018 12:12
Show Gist options
  • Save mertkahyaoglu/19efc9699d667a4ac139fd0b42b284bd to your computer and use it in GitHub Desktop.
Save mertkahyaoglu/19efc9699d667a4ac139fd0b42b284bd 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:])
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