Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pimp_flatten2.py
- test = [1, (2, [3, [(4, 5), ['[abc]', ([6], [7, 8]), 9]]]), 0]
- print(test)
- def f(z,r=[]):
- if len(z):
- if z[0]*0 in [(),[]]:
- f(z[0])
- else:
- r.append(z[0])
- f(z[1:],r)
- return r
- 0
- print f(test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement