Check a String is Uppercase in Python

  • Post category:String

In this article, you will see how to check a string is uppercase in Python. An uppercase string is a string that contains only uppercase letters. The string isupper() method returns True if all characters in the string are uppercase, otherwise False.

Step 1: Create a string

str = "CODEALLOW"
print("str = ", str)
print("str type = ", type(str))

Step 2: Check if a string is uppercase

if all(c.isupper() for c in str):
    print("Uppercase")
else:
    print("Not Uppercase")

Output:

str =  CODEALLOW
str type =  <class 'str'>
Uppercase

Free resources to learn advanced skills: AiHints and CodeAllow