Suppose this string:
The fox jumped over the log.
Turning into:
This does and will do: :)
# python... 3.x import operator ... # line: line of text return " ".join(filter(lambda a: operator.is_not(a, ""), line.strip().split(" ")))