Skip to content

Commit

Permalink
Merge pull request keon#3 from cclauss/patch-1
Browse files Browse the repository at this point in the history
Deal with garbage in a, Deal with tuples
  • Loading branch information
keon authored Apr 18, 2017
2 parents d0a0ce6 + 1a53f6f commit 95c10f6
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions array/flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@


def list_flatten(l, a=None):
# check a
if a is None:
# initialize with empty list
a = []

a = list(a) if isinstance(a, (list, tuple)) else []
for i in l:
if isinstance(i, list):
if isinstance(i, (list, tuple)):
list_flatten(i, a)
else:
a.append(i)
Expand Down

0 comments on commit 95c10f6

Please sign in to comment.