Python Tutorial Python Advanced Python Resources Python Libraries
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

Python - String isspace() Method



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

5