Advertisement
here2share

# pimp_flatten.py

Jan 1st, 2020
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. # pimp_flatten.py
  2.  
  3. test = [1, (2, [3, [(4, 5), ['[abc]', ([6], [7, 8]), 9]]]), 0]
  4. def flatten(m): return [p for i in m for p in (flatten(i) if isinstance(i,(list,tuple)) else [i])]
  5. print(flatten(test))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement