Skip to content

Commit

Permalink
Deal with garbage in a, Deal with tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored Apr 17, 2017
1 parent d0a0ce6 commit 1a53f6f
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 1a53f6f

Please sign in to comment.