Home >>Python String Methods >Python String isspace() Method
Python String isspace() Method in python is used to check space in the string and it returns true if all the characters in a string are whitespace otherwise, it returns false.
Syntax:string.isspace()Here is an example of Python String isspace() Method:
isspace = " "
x = isspace.isspace()
print(x)
str = " "
if str.isspace() == True:
print("It contains space")
else:
print("Not space")
str = "ab cd ef \n"
if str.isspace() == True:
print("It contains space")
else:
print("Not space")
str = "\t \r \n"
if str.isspace() == True:
print("It contains space")
else:
print("Not space")