Python isupper() Method [with Examples]
Case sensitive refers to the fact that «A» differs from «a». A Python program differentiates between «a» and «A.» Python requires close attention to the string’s case while developing code. Numerous helpful built-in functions in the Python programming language check the case of the supplied strings. The Python functions lower() , islower() , upper() , and isupper() are a few that can be used with strings. In this short article, we will learn how we can use the Python isupper method to check if the string is in upper case or not by solving various examples.
Introduction to Python isupper() method
The Python standard library has a built-in function called Python isupper() method. It supports the use of strings and other types of data. It shows whether a string of characters contains only capital letters or not. If at least one character is lowercase, it returns FALSE. Otherwise, if every letter in the string is capitalized, it returns TRUE.
The following is the syntax of the Python isupper method:
The string is the name of the variable where you have stored the string. The isupper method checks whether the given string is in upper case letters or not.
Example 1: Using python isupper()
Now we will take three different strings and apply the Python isupper method to check whether the given strings are in upper case or not. See the example below;
As you can see, only the first string is True because all the alphabets are in upper case while we get False for string two and string three as they have some lower case alphabets.
Example 2: Check the string case from the user input
Now we will take a string input from the user and will check if the input from the user is in upper case or not. We will use the if-else statement to check the string.

As you can see, I entered all the letters in the upper case which is why we get Yes. If you will enter something in lowercase, the program will print No .
Example3: Count total upper case words
So far, we demonstrated only simple examples to understand the function of the isupper() method of the standard Python library. However, this function can be used with any complex and difficult problems. It has numerous practical uses in multiple areas.
Now, we will use the split function along with the isupper() method to count the total number of words which are in upper case in the given sentence. First, we will define a string and then will use the split function to split the sentence into words. Finally, we will use the for loop to iterate through the words and
count all those which are in upper case.
Example 4: Convert words to uppercase
Extending the previous example, we iterate through each item in the string. If a specified item is already in upper case, simply print it. If it is not, convert it into the upper case and return the string in the upper case.
As you can see, we get full details about the lower case and upper case words and the above program has converted the lower case words to upper case.
Summary
The Python isupper() method checks whether all the characters of a given string are uppercase or not. It returns True if all characters are uppercase and False even if one character is not in uppercase. In this short article, we learned how we can use the python isupper method to check if the letter or word is in upper case. We solved various examples using Python.
Further reading
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.
For any other feedbacks or questions you can either use the comments section or contact me form.