Python String isupper
Now, we are going to learn about the isupper method. As the name of the method says, the isupper method is used to check if all the alphabets in the string are in uppercase. So, if we are required to check whether or not all the characters in the string are in the uppercase, we can make use of the isupper method to achieve this. This method will return True if all the characters in the string are in uppercase, and False otherwise. Let’s have a look at an example, which demonstrates the same thing.
Python String isupper() Method
As you can see, we have a string, in which, all the alphabets are in the uppercase, so the isupper method is going to return True in this case. You can also try some other examples. Now, Let’s consider that there is a string, in which all the alphabets are not in uppercase. In such a situation, the return value from the method is going to be False. Let’s have a look at a simple example, which tries to demonstrate the same thing.
As you can see in the above program, we have a string, in which, not all the alphabets are in uppercase. In such a situation, the return value from the method is False. You can try executing the program and checking the output.
Also, the thing is that if we are having a string, in which there are some characters other than alphabets, it is not going to affect the output here. For example, Let’s consider the below program.
As you can see in the above program, we have a string, in which there are some characters other than alphabets. But still, if we try executing the program and check the output, the output comes out to be True, since all the alphabets are there in the uppercase.
So, as and when required, we can make use of the isupper method in our python programs. Remember that the method returns True or False, on the basis of whether or not, all the alphabets in the string are in uppercase.