Python string isupper( ) method determines if a string character is uppercase. If the string passed in is a Unicode string, single character, then the method will check each character in the string and determine if it is uppercase letter. If the character is a letter, then the character will be uppercase. If the character is a number, then the character will be lowercase
Table of Contents
Practical Application of isupper() Method
In order to understand the practical application of the isupper( ) method in python, we need to know what this function does. The isupper() function takes two strings as input and returns a boolean indicating if one string is upper than the other. For example, the “A” isupper function will return true because “A” is in the upper case.
To get better understanding let us have a look on the following code examples,
Example 1
string = "WELCOME TO CODELEAKS"
string2 = string.isupper()
print(string2)
Output

Example 2
string = "welcome to codeleaks"
string2 = string.isupper()
print(string2)
Output

Isupper() Method with Numbers and Special Characters
Because the isupper function works on strings rather than numbers and special characters, it will return only false if there are just numbers and special symbols in the given string.
string_name = "3764726"
print(string_name.isupper())
string_name = "@$&*("
print(string_name.isupper())
Output

Advantage of isupper() Method in Python
The real advantage of Python’s library is that it can be used in other contexts, such as data validation! For example, you can use it to ensure your user inputs only valid characters when they act on your sites, like registering or logging in. Using these methods correctly will make your code more secure and accurate simultaneously.
FAQs
How do you use isupper in a for loop in Python?
If the string is ‘WELCOME TO CODELEAKS,’ then it has a value of If isupper()==True, print(‘string is in upper case’); else, print(‘string is in lower case’).
What is the return value of isupper method in python?
Bool is the return value, for example. Whether all of the string’s alphabets are in uppercase, it returns either True or False.
Also visit the article Python String Splitlines() method to learn more about string methods in Python.
Conclusion
In this article, we explained that a Python string isupper( ) method returns True if the string is uppercase and False otherwise. The method is simple but can come in handy when debugging code. Now you also know how to use this helpful string method in Python. Before writing more codes, ensure your strings are lowercase and uppercase. Happy Coding.