English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The isupper() method of the string returns whether all characters in the string are uppercase.
The syntax of the isupper() method is:
string.isupper()
The isupper() method does not take any parameters.
The isupper() method returns:
True If all characters in the string are uppercase
False If any character in the string is lowercase
# empty string string = "THIS IS GOOD!" print(string.isupper()); # Replace letters with numbers string = "THIS IS ALSO G00D!" print(string.isupper()); # lowercase string string = "THIS IS not GOOD!" print(string.isupper());
When running the program, the output is:
True True False
string = 'THIS IS GOOD' if string.isupper() == True: print('Does not contain lowercase letters.') else: print('Contains lowercase letters.') string = 'THIS IS gOOD' if string.isupper() == True: print('Does not contain lowercase letters.') else: print('Contains lowercase letters.')
When running the program, the output is:
Does not contain lowercase letters. Contains lowercase letters.