Python String isspace() Method


Advertisements


Description

The method isspace() 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.

Live Demo
#!/usr/bin/python

str = "       "; 
print str.isspace()

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

When we run above program, it produces following result −

True
False

python_strings.htm

Advertisements