Python String isspace() Method


Contents

Description

The isspace() method in Python String checks if the string consists of whitespace. In Python, isspace() refers to an inbuilt method used for string handling. It returns True when all the characters in the string consist of whitespace characters, else, It returns False. This function is therefore used for checking whether the argument consists of all the whitespace characters like : ' ' – Space.

Syntax

Here is the syntax for isspace() method:

str.isspace()

Parameters

  • NA

Return Value

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

Example

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

#!/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

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.



Navigation
Tutorial
Tutorial
Tutorial