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.

Sign Up for Our Newsletters

Get notified of the best deals on our WordPress themes.

You May Also Like
Convert String To Float In Python

Convert String to Float in Python

Table of Contents Hide Convert string to float in Pythonfloat() functionExample 1 – Convert string to floatExample 2 – Default float conversion without any input parameterExample 3 – Convert a…
View Post
Python Enumerate()

Python enumerate()

Table of Contents Hide enumerate() Syntax enumerate() Parametersenumerate() Return ValueExample 1: How enumerate() method works in Python?Example 2: Using Enumerate object in loops The enumerate() in Python is a built-in function that adds…
View Post
Python String Swapcase()

Python String swapcase()

Table of Contents Hide swapcase() Syntaxswapcase() Parametersswapcase() Return ValueExample: Python Program to change the case of a given string Python string swapcase() method is a built-in function that converts all…
View Post
Python Bytearray()

Python bytearray()

Table of Contents Hide bytearray() Syntax bytearray() Parametersbytearray() Return ValueExample 1: Array of bytes of given integer sizeExample 2: Array of bytes from a stringExample 3: Array of bytes from an…
View Post