Python String isspace() Method
Returns True if all characters in the string are whitespace. Tabs, carriage returns and line feeds are considered to be whitespace.
Syntax
Python
Copy Code
string.isspace()
Example
Python
Copy Code
print('Checking space is a space: ', ' '.isspace()) print('Checking tab is a space: ', '\t'.isspace()) print('Checking newline/carriage return is a space: ', '\r\n'.isspace()) print('Checking ABC DEF is a space: ', 'ABC DEF'.isspace())
Output
Checking space is a space: True Checking tab is a space: True Checking newline/carriage return is a space: True Checking ABC DEF is a space: False