Python String isupper()
Python String isupper() method checks if the given string contains alphabets that are uppercase only. isupper() method returns True if each of the alphabet present in given string is only a uppercase alphabet (A-Z), or False otherwise.
In this tutorial, we will learn the syntax and examples for isupper() method of String class.
Syntax
The syntax to call isupper() method on a string x
in Python is
x.isupper()
Examples
In the following program, we take a string 'APPLE'
, and check if this string contains only uppercase alphabets, using isupper()
method.
Example.py
x = 'APPLE'
result = x.isupper()
print(result)
Output
True
In the following program, we take a string 'Apple'
, and check if this string contains only uppercase alphabets, using isupper()
method. Since the string contains some lowercase alphabets, isupper() returns False.
Example.py
x = 'Apple'
result = x.isupper()
print(result)
Output
False
Conclusion
In this Python Tutorial, we learned how to check if given string contains alphabets that are only lowercase, using String method – isupper().