How to Use String isspace() Method in PythonPython Basics


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.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us