Python string isupper() method
Python String isupper() Method
Description
The isupper() method checks whether all case-based characters (letters) in a string are uppercase.
Syntax
The syntax of the isupper() method is as follows:
var.isupper()
Parameters
None
Return Value
This method returns true if all case-based characters in the string are uppercase and there is at least one lowercase character, otherwise it returns false. Numbers and symbols are ignored.
Example
The following example demonstrates the use of the isupper() method.
var = "Hello Python"
var1 = var.upper().isupper()
print ("Original string:", var)
print ("Is it all uppercase?:", var1)
var = "UPPER CASE"
var2 = var.isupper()
print ("Original string:", var)
print ("Is it all uppercase?:", var2)
var = "HYDERABAD 500081"
var3 = var.isupper()
print ("Original string:", var)
print ("Is it all uppercase?:", var3)
Running this program will produce the following output −
Original string: Hello Python
Is it all uppercase?: True
Original string: UPPERCASE
Is it all uppercase?: False
Original string: HYDERABAD 500081
Is it all uppercase?: True