Python isupper() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
String

Definition

isupper() returns True when the string has at least one letter and every letter is upper case. Digits, spaces, underscores, and punctuation have no case, so they are ignored: "MAX_SIZE 10!" is upper case.

A string with no letters, such as "123" or "", returns False. One lower case letter anywhere makes the result False.

text.isupper() is a method of the built-in str type: call it on a string with dot notation. No import is needed, and it never changes the original string.

Syntax

Call it on any string. There are no arguments, but the parentheses are required.

python
ok = text.isupper()
CallWhat it does
"HELLO 123".isupper()Returns True. Every letter is a capital, and the digits are ignored.
"Hello".isupper()Returns False. The letters ello are lower case.
"123".isupper()Returns False. There is no letter, so nothing is upper case.

The opposite check is islower(). To convert instead of test, use upper().

Library declarations
python
str.isupper() -> bool
# returns: True if there is at least one cased letter and all are upper case
# an empty string returns False

Parameters

This method takes no arguments. It always checks the whole string.

Return Value

Return ValueDescription
boolTrue if the string has at least one letter and all of its letters are upper case, otherwise False.

Python Examples

Example 1 — Is This Text Upper Case?

Run the check on mixed text, a number, and an empty string.

python
for text in ["PYTHON", "Python", "PYTHON 3.12!", "2024", ""]:
    print(repr(text), text.isupper())

How It Works

  1. All capitals. "PYTHON" is upper case, so the result is True.
  2. One small letter is enough. "Python" has lower case letters after the first one, so it is False.
  3. Digits are ignored. "PYTHON 3.12!" passes, because the digits, dot, and space have no case.
  4. No letters, no upper case. The number and the empty string both return False.

Example 2 — Spot Messages Written in Capitals

Count how many chat messages are written entirely in capitals.

python
chat = ["hello team", "URGENT: CALL NOW", "ok", "ASAP", "see you at 5"]
loud = [msg for msg in chat if msg.isupper()]

print(loud)
print(len(loud), "of", len(chat))

How It Works

  1. A filter. A message is kept when msg.isupper() is True.
  2. Punctuation is ignored. The colon and spaces in URGENT: CALL NOW have no case, so the message still counts.
  3. Report the count. Two of the five messages are written in capitals.

Example 3 — Check Constant Naming

Constants in Python are written in capitals, so the check can find names that break the habit.

python
names = ["MAX_SIZE", "max_size", "Max_Size", "PI", "E2"]

constants = [n for n in names if n.isupper()]
others = [n for n in names if not n.isupper()]

print(constants)
print(others)

How It Works

  1. Underscores are ignored. MAX_SIZE passes, because the underscore has no case and the letters are all capitals.
  2. Digits are ignored too. E2 has one capital letter and a digit, so it counts.
  3. Split into two lists. not n.isupper() collects the names that are lower case or mixed.

Frequently Asked Questions

It returns True if the string has at least one letter and every letter is upper case. Digits, spaces, and punctuation are ignored.
False. The string needs at least one letter to count as upper case.
Yes. They have no case, so "MAX_SIZE_2" is upper case, while "2024" has no letters and gives False.
No. A string such as "Hello" or "123" is neither upper case nor lower case, so both checks return False for it.
Call upper(), for example text = text.upper(). It returns a new string with every letter converted to a capital.

Next: join()

Join the strings of an iterable into one string, with the separator between them.

join() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful