string.isspace()
The isspace() method returns:
True
if all characters in the string are whitespace charactersFalse
if the string is empty or contains at least one non-printable() characterstring = ' 'print(string.isspace())string = ' a 'print(string.isspace())string = ''print(string.isspace())
string = ' \n'if string.isspace() == True:print('All whitespace characters')else:print('Contains non-whitespace characters')string = '2+2 = 4'if string.isspace() == True:print('All whitespace characters')else:print('Contains non-whitespace characters.')
**********END OF ARTICLE **********
Comments