Last active
April 23, 2019 20:39
-
-
Save marcodebe/e04e4f24dd82739289971996d33991c3 to your computer and use it in GitHub Desktop.
Revisions
-
marcodebe revised this gist
Apr 23, 2019 . No changes.There are no files selected for viewing
-
marcodebe revised this gist
Apr 23, 2019 . 1 changed file with 8 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,12 @@ def flatten(l): if isinstance(l, list): out = [] out = flatten(l.pop()) + out if l: out = flatten(l) + out return out return [l] # Example l = [3, 1, [4, 1], [[5], [9]], [2, [6, 5]]] print(flatten(l)) -
marcodebe created this gist
Mar 1, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ def flatten(l): if isinstance(l, int): return [l] out = [] out = flatten(l.pop()) + out if l: out = flatten(l) + out return out # Example l = [3,1,[4,1], [[5],[9]], [2, [6,5]]] print(flatten(l))