Advertisement
here2share

# pimp_flatten2.py

Jan 1st, 2020
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. # pimp_flatten2.py
  2.  
  3. test = [1, (2, [3, [(4, 5), ['[abc]', ([6], [7, 8]), 9]]]), 0]
  4. print(test)
  5.  
  6. def f(z,r=[]):
  7.     if len(z):
  8.         if z[0]*0 in [(),[]]:
  9.             f(z[0])
  10.         else:
  11.             r.append(z[0])
  12.         f(z[1:],r)
  13.     return r
  14. 0
  15.  
  16. print f(test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement