Python 3 - String isspace() Method


Description

The isspace() method checks whether the string consists of whitespace.

Syntax

Following is the syntax for isspace() method −

str.isspace()

Parameters

NA

Return Value

This method returns true if there are only whitespace characters in the string and there is at least one character, false otherwise.

Example

The following example shows the usage of isspace() method.

#!/usr/bin/python3

str = "       " 
print (str.isspace())

str = "This is string example....wow!!!"
print (str.isspace())

Result

When we run above program, it produces the following result −

True
False
python_strings.htm
Advertisements