Advertisement
here2share

# sublists_flatten.py

May 8th, 2015
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. # sublists_flatten.py
  2.  
  3. L1 = [1, 2, 3]
  4. L2 = [4, 5, [], 6]
  5. L3 = [7, 8, 9, 'z']
  6. L = [L1, L2, L3]
  7.  
  8. s=[x for y in L for x in y]
  9. print s
  10.  
  11. ### ... or even better... ###
  12.  
  13. print sum(L,[])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement