Say I have a string that can contain different characters:
e.g. word = "UPPER£CASe"
How would I test the string to see if all the characters are uppercase and no other punctuation, numbers, lowercase letters etc?
To check if a string is in uppercase, we can use the isupper() method. isupper() checks whether every case-based character in a string is in uppercase, and returns a True or False value depending on the outcome.
To check whether a character is in Uppercase or not in Java, use the Character. isUpperCase() method.
To check if a character is upper-case, we can simply use isupper() function call on the said character.
C isupper() The isupper() function checks whether a character is an uppercase alphabet (A-Z) or not.
You should use str.isupper()
and str.isalpha()
function.
Eg.
is_all_uppercase = word.isupper() and word.isalpha()
According to the docs:
S.isupper() -> bool
Return
True
if all cased characters inS
are uppercase and there is at least one cased character inS
,False
otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With