Remove empty and whitespace-only strings
Input
skip_empty(["a", "", "b", " ", "c"])
Output
['a', 'b', 'c']
Empty string and a single-space string are removed, others kept in order.
Full lesson preview
Filter out empty or whitespace-only strings from a list while preserving order.
Problem statement
Task
Examples
Input
skip_empty(["a", "", "b", " ", "c"])
Output
['a', 'b', 'c']
Empty string and a single-space string are removed, others kept in order.
Input format
Output format
Constraints
Samples
Input
skip_empty(["hello", " world "])
Output
['hello', ' world ']
Strings with surrounding or internal whitespace but containing characters are kept unchanged.