Try
list2 = [x for x in list1 if x != []]
If you want to get rid of everything that is “falsy”, e.g. empty strings, empty tuples, zeros, you could also use
list2 = [x for x in list1 if x]
More Related Contents:
- Replace list object based on indexes of another list (Python)
- User input integer list [duplicate]
- Transpose list of lists
- Sorting list based on values from another list
- Circular list iterator in Python
- 2D list has weird behavor when trying to modify a single value [duplicate]
- python filter list of dictionaries based on key value
- How to iterate over a list in chunks
- How do I remove duplicates from a list, while preserving order?
- Merging dictionary value lists in python
- Check if an item is in a nested list
- Making a python iterator go backwards?
- How do I serialize a Python dictionary into a string, and then back to a dictionary?
- Insert element in Python list after every nth element
- python pandas flatten a dataframe to a list
- Python split for lists
- What is the difference between sets and lists in Python?
- Best and/or fastest way to create lists in python
- What is the ‘pythonic’ equivalent to the ‘fold’ function from functional programming?
- Removing Punctuation From Python List Items
- Multiply operator applied to list(data structure)
- Co-occurrence matrix from nested list of words
- Using a dict to translate numbers to letters in python
- How can I make a dictionary (dict) from separate lists of keys and values?
- Zip with list output instead of tuple
- How can I avoid “RuntimeError: dictionary changed size during iteration” error?
- How to split by comma and strip white spaces in Python?
- How to create multiple lists? [duplicate]
- Find starting and ending indices of sublist in list
- Converting List Comprehensions to For Loops in Python