The isupper
method will return True
if all the alphabetical characters present in the string are in uppercase. If any character of the string is in lowercase, or no alphabetical character is present in the string, then False
is returned.
string.isupper()
True
:
False
in any one of the below cases:
If any character of the string is lowercase.
If no alphabetical character is present in the string.
# True - because all characters are lowercasestring = 'ALL UPPER';print(string.isupper())# False - because string has lowercase character - rstring = 'LOWEr';print(string.isupper())# False - because no alphabetical character presentstring = '10';print(string.isupper())# True - because one alphabetical character present and that character is in upper casestring = '12B';print(string.isupper())# False - because one alphabetical character present and that character is not lower casestring = '12b';print(string.isupper())
In the above code, we call the isupper
method:
For the string ALL UPPER
, the isupper
will return True
because all the characters of the string are uppercase letters.
For the string LOWEr
, the isupper
will return False
because the string contains one lowercase letter (r
).
For the string 10
, the isupper
will return False
because the string contains no alphabetical letter.
For the string 12B
, the isupper
will return True
because the string has one alphabetical character and that character is in uppercase.
For the string 12b
, the isupper
will return False
because the string has one lowercase character.