Menu Close

Python String isupper() Method

python string isupper

In this tutorial, you will learn everything about the Python string isupper() method to check whether a string contains all uppercase characters or not. In the previous tutorial, we have seen the Python string islower() method to check whether a string contains all lowercase characters or not.

Python String isupper() Method

Python string isupper() function is a string built-in function that is used to return True or False. If the string contains all uppercase characters, it returns True otherwise it will return False.

Syntax:

The syntax of string isupper() method.

string.isupper()

Parameter:

The String isupper() method does not accept any parameter.

Return Type:

isupper() function in Python returns a Boolean value. True or False.

Let’s see an example of using the python isupper() string method.

Python String isupper Example:

Here we will take some examples to understand the Python string isupper() method.

Example 1:


str = "python"
str2 = str.isupper()
print(str2)

The output will be:- False

Example 2:


str = "PROGRAMMING 12"
str2 = str.isupper()
print(str2)

The output will be:- True

Example 2:


str = "Programming"
str2 = str.isupper()
print(str2)

The output will be:- False

Example: Using isupper() in a Python program

In this example, I have printed some messages according to the user input value.


value = input("Please enter your name here:- ")
if value.isupper():
    print(f"Your entered value is here '{value}' and all the characters is in uppercase.")
else:
    print("Your entered value didn't contain uppercase characters.")

Output

If the user will enter all uppercase characters string.

Please enter your name here:- PYTHON
Your entered value is here 'PYTHON' and all the characters is in uppercase.

If the user will enter a string with lowercase characters.

Please enter your name here:- Python
Your entered value didn't contain uppercase characters.

Conclusion:

In this tutorial, you have learned about the Python string isupper() method to check whether a string contains all uppercase characters or not. If all characters are in uppercase, will return True otherwise it will return False.

I hope this article will help you. if you like this article, please share it with your friends who want to learn Python programming.

For More Information:- Click Here

Python String endswith() Method

Related Posts