Advertisement
here2share

# list_compact.py

Oct 10th, 2019
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. # list_compact.py
  2.  
  3. def compact(lst):
  4.     return list(filter(None, lst))
  5.  
  6. print compact([0, 1, False, 2, '', 3, 'a', None, 's', {0: ''}, 34, 0.0, ()])
  7.  
  8. # [ 1, 2, 3, 'a', 's', {0: ''}, 34 ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement