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