Signup/Sign In

Python String isupper()

The Python isupper() string method returns true if all the characters of a string are in uppercase.

  • The isupper() method is an in-built method for string handling.

  • If all case-based characters (letters) of a string are in uppercase then this method returns true otherwise returns false.

  • This method returns true for whitespace if all other characters in the given string are alphabet and in uppercase. For a string with only whitespaces, this method will return false.

Python String isupper(): Syntax

Below we have a basic syntax of the isupper() method in Python:

string.isupper()

Note: In the above syntax string denotes the string variable on which isupper() method will be applied.

Python String isupper(): Parameters

From the syntax it is clear that this method does not take any parameters. If any parameter will be passed then it will raise an error.

Python String isupper(): Returned Values

This method returns true if all characters of a string are in uppercase.

Python String isupper(): Basic Example

Below we have an example to show the working of the isupper() function:

str = 'WE ARE IN THE TITANIC NOW'
print(str.isupper())

The Output will be:


true

Python isupper() method: Another Example

There is another example where all letters are not in uppercase:

str = "We are in StudyTonight"
print(str.isupper())

The Output will be:


false

Time for a Live Example!

Now its time to look at a live example let us see it is given below:

Summary

This tutorial covers the isupper() method of strings in Python which returns true if all characters of a string are in uppercase; it returns false for digits, symbols, and whitespaces.



About the author:
Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.