Python String isspace() MethodPython Functions

Difficulty Level:
Difficulty Level:

The isspace() method determines whether a string consists of only whitespace characters.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

str1 = "Merry Christimas!"
str2 = "        "

print (str1.isspace())
print (str2.isspace())

Output:

False
True

Syntax

string.isspace()

Parameters

The method doesn’t take any parameters.

Return Value

It returns True or False, depending on whether only whitespace characters are found in the string.

Advertisement

© 2021 Pythonexample.org, all rights reserved. Privacy Policy | Contact Us