Python String isupper()

Python String isupper() method is a built-in function that returns True if all the characters in the string are uppercase. If the string contains at least one lowercase character, the method returns False.

Syntax

The syntax of isupper() method is:

string.isupper()

Parameter

The isupper() method doesn’t take any parameters.

Return Value

The isupper() method returns:

  • True if all alphabets in a string are uppercase alphabets.
  • False if the string contains one or more lowercase alphabets.

Example 1: Demonstrating the working of isupper() method

text1="ITSMYCODe"
text2="ITSMYCODE"

print("Is ITSMYCODe all uppercase:",text1.isupper())
print("Is ITSMYCODE all uppercase:",text2.isupper())

Output

Is ITSMYCODe all uppercase: False
Is ITSMYCODE all uppercase: True

Example 2: Practical use case of isupper() in a program

The following program will determine if the given sentence consists of all uppercase characters.

text1 = "PYTHON IS fun"
text2 = "WELCOME TO PYTHON TUTORIALS"

if(text1.isupper()==True):
    print("The text contains all uppercase characters")
else:
    print("The text contains at least one lowercase characters")

if(text2.isupper()==True):
    print("The text contains all uppercase characters")
else:
    print("The text contains at least one lowercase characters")

Output

The text contains at least one lowercase characters
The text contains all uppercase characters
Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like