Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # remove_empty_strings_from_a_list.py
- str_list = ["", None, '', 0, "Hi", '', '', 'Python!', '', False, 123]
- str_list = [x for x in str_list if x != '']
- print str_list
- # many times faster, but might be an overkill...
- mylist = ["", None, '', 0, "Hi", '', '', 'Python!', '', False, 123]
- mylist = filter(None, mylist)
- print mylist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement