isupper() string method in Python
The isupper() string method checks whether all cased characters in a string are uppercase.
- Returns True if all cased characters in the string are uppercase.
- Returns False if any cased character is lowercase.
- Returns False if there are no cased characters in the string.
Syntax
string.isupper()
Example:
Python
print('BANANA'.isupper()) # True
# All letters are uppercase
print('banana'.isupper()) # False
# All letters are lowercase
print('baNana'.isupper()) # False
# Mixed case, not all uppercase
print(' '.isupper()) # False
# No cased letters in the string
print('123!'.isupper()) # False
# No cased letters, only numbers and symbols Special Notes
- Only cased letters are considered; digits, spaces, and punctuation are ignored.
- The method is useful for validating uppercase text, such as acronyms or codes.