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.

isupper() Syntax

The syntax of isupper() method is:

string.isupper()

isupper() Parameter

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

isupper() 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

Get notified of the best deals on our WordPress themes.

You May Also Like
List of Python free ebooks

List of Free Python Books

Table of Contents Hide Python SuccinctlyPython Data Science HandbookThink Python 2nd EditionAutomate the Boring Stuff with PythonMaking Games with Python & PygameData Structures and Algorithms in Python Google Python Style GuideA…
View Post