Skip to content
Related Articles

Related Articles

Python String isupper() method
  • Last Updated : 03 Dec, 2020

Python has many utility functions in its libraries that always help us to achieve some common day-day task. Let’s see the working of string isupper() method which actually checks if all characters in the string are uppercase.

Syntax : string.isupper()

Parameters : None

Returns : True if all the letters in the string are in upper case and False if even one of them is in lower case.

Code #1 : Demonstrating the working of isupper()

# Python3 code to demonstrate
# working of isupper()
# initializing string 
isupp_str = "GEEKSFORGEEKS"
not_isupp = "Geeksforgeeks"
# Checking which string is 
# completely uppercase
print ("Is GEEKSFORGEEKS full uppercase ? : " + str(isupp_str.isupper()))
print ("Is Geeksforgeeks full uppercase ? : " + str(not_isupp.isupper()))


Is GEEKSFORGEEKS full uppercase ? : True
Is Geeksforgeeks full uppercase ? : False


Practical Application: This function can be used in many ways and has many practical applications. One such application for checking the upper cases, checking Abbreviations (usually upper case), checking for correctness of sentence which requires all upper cases. Demonstrated below is small example showing the application of isupper() method.

Code #2 : Demonstrating the practical application of isupper()

# Python3 code to demonstrate
# application of isupper()
# checking for abbreviations.
# short form of work/phrase
test_str = "Cyware is US based MNC and works in IOT technology"
# splitting string 
list_str = test_str.split()
count = 0
# counting upper cases
for i in list_str:
    if (i.isupper()):
        count = count + 1
# printing abbreviations count 
print ("Number of abbreviations in this sentence is : " + str(count))

Output :

Number of abbreviations in this sentence is : 3

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :