Python Reference ยท String Methods
Python str.isupper() method
Reference for Python str.isupper(): test whether all cased characters are upper case, how digits and punctuation are ignored, and how it relates to upper().
The isupper() method returns True if the string contains at least one cased character and every cased character is upper case. Digits, spaces and punctuation have no case and are ignored, so "HELLO, WORLD 2" is upper case.
It only reports; it does not change the string. Use upper() to convert.
print("PYTHON".isupper()) # True print("Python".isupper()) # False
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.
Syntax
str.isupper()
This method takes no parameters.
Return value: True if the string has at least one cased character and no lower-case or title-case characters; otherwise False.
Raises: nothing.
Usage notes
- A letter is required.
"123".isupper()and"".isupper()areFalse. - Any lower-case letter fails.
"HELLo"isFalse, wherever the lower-case letter is. - Ignores uncased characters.
"A1 B2!"isTrue. This is whyisupper()is useful for checking constant-style names likeMAX_SIZE. - Not the opposite of
islower(). A mixed string like"Hello"is neither, and so is"123". - Unicode. It works with any alphabet that has case. Some letters have no upper-case form of themselves, such as
ร:"ร".isupper()isFalse, even though"ร".upper()gives"SS". - Title-case letters like
วcount as not upper case. - Bytes have
bytes.isupper()for ASCII only.