I have a variable called "string" in python. How can I check that my variable does not contain only whitespace, but has an actual character in it? If the variable contains only whitespace, I don't want to print it. If it has a character in it, then I want to print the variable.
Asked
Active
Viewed 679 times
-1
-
You can do it like so: `if line.strip()` – Anwarvic May 27 '20 at 10:26