Recommended Free Tools
To remove only exact empty strings from a Python list, use a list comprehension with an explicit comparison:
items = ["apple", "", "banana", ""]
result = [item for item in items if item != ""]
# ['apple', 'banana']
This creates a new list, keeps the original order, and leaves whitespace-only strings, None, and other values untouched.
As an Amazon Associate I earn from qualifying purchases.
Remove only zero-length strings
The condition item != "" excludes strings whose length is zero. Every other value passes the test, including " " (a space), None, 0, and False. That makes this the clearest option when “empty” means exactly "".
A list comprehension builds a new list from the items that meet its condition. See the Python built-in types documentation.
#1 Best Overall
Remove whitespace-only strings too
If entries containing only whitespace should also be discarded, test each string with strip():
items = ["apple", "", " ", " banana "]
result = [item for item in items if item.strip()]
# ['apple', ' banana ']
strip() returns a copy with leading and trailing whitespace removed. Here, the trimmed copy is used only for the condition: retained strings stay unchanged, so " banana " keeps its surrounding spaces. If you want to normalize retained strings as well, put the transformation in the output expression:
Rank #2
result = [item.strip() for item in items if item.strip()]
This version removes whitespace-only entries and trims whitespace from every retained string.
Free tools Windows power users keep installed
One-click scans. No signup required.
Choose a filter that matches the data
| Goal | Expression | What it removes |
|---|---|---|
| Exact empty strings | [item for item in items if item != ""] |
Only "" |
| Empty and whitespace-only strings | [item for item in items if item.strip()] |
"" and strings that become empty after trimming |
| All falsy values | list(filter(None, items)) |
Every value that evaluates as false, not just empty strings |
filter(None, items) can also discard values such as None, 0, and False. Use it only when removing every falsy value is actually the goal. Python’s Functional Programming HOWTO explains predicate-based filtering and its list-comprehension equivalent.
Use filter() for an explicit predicate
For a string-only list, this produces the same result as the exact-empty-string comprehension:
result = list(filter(lambda item: item != "", items))
filter() returns an iterator, so list() materializes it as a list. For a simple condition, the comprehension usually makes the rule easier to see at a glance.
Replace the original list when needed
A comprehension assigns a new list to result; it does not change items. If other parts of your program hold a reference to items and must see the filtered contents, assign to the full slice instead:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
items[:] = [item for item in items if item != ""]
This replaces the contents while preserving the identity of the list object. Avoid removing matching elements with remove() while looping over that same list: deletion shifts later elements, which can cause a loop to skip a match. Python’s data structures tutorial documents list operations.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




