Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python String 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 below example, 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