Skip to content
Tutorials Center
My learning

Topics

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.

Python
print("PYTHON".isupper())   # True
print("Python".isupper())   # False

Try it

Python Upper-case checks

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.

Python Spotting constants and shouting

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

Python
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() are False.
  • Any lower-case letter fails. "HELLo" is False, wherever the lower-case letter is.
  • Ignores uncased characters. "A1 B2!" is True. This is why isupper() is useful for checking constant-style names like MAX_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() is False, even though "รŸ".upper() gives "SS".
  • Title-case letters like ว… count as not upper case.
  • Bytes have bytes.isupper() for ASCII only.