Python String - isspace() Method
The Python isspace() method is used to check whether all characters of the string are whitespaces or not. It returns true when all characters of the string are whitespaces, else returns false.
Syntax
string.isspace()
Parameters
No parameter is required.
Return Value
Returns True if all characters of the specified string are whitespaces, else returns False.
Example:
In the example below, isspace() method is used to check whether all characters of the given string are whitespaces or not.
MyString = "Hello World!" print(MyString.isspace()) MyString = " " print(MyString.isspace())
The output of the above code will be:
False True
❮ Python String Methods