Python - String isspace() Method


Advertisements

The 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.

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())

Output

False

True

String Methods
Advertisements