Remove Whitespace

Remove all whitespace characters from a string.

PythonBeginner
Python
# Program to remove all whitespace from a string

s = input("Enter a string: ")

no_space = "".join(ch for ch in s if not ch.isspace())

print("Without whitespace:", no_space)

Output

Enter a string: hello world
Without whitespace: helloworld

We filter out characters for which .isspace() is True.