Tutorial Study Image

Python isupper()

The isupper() function in python helps to check whether all the alphabets in the string are uppercase. The function returns True if all the alphabets are uppercase. If it contains at least one lowercase letter then it will return False.


string.isupper() 
 

isupper() Parameters:

The isupper() method doesn't take any parameters.The function will check only alphabet characters no numbers, symbols, and spaces are checked.

isupper() Return Value

The return value is always a boolean value. If a given string contains only symbols or numbers, and if it is an empty string this method will return false. The string that needs to be checked must contain at least one alphabet char.

Input Return Value
all uppercase alphabets True
at least one lowercase False

Examples of isupper() method in Python

Example 1: How isupper() method works in Python?


string = 'PYTHON PROGRAMMING'
print(string.isupper())

string = 'PYTHON123 PROGRAMMING345'
print(string.isupper())

string = 'Hi PYTHON'
print(string.isupper())
 

Output:


True
True
False

Example 2: How to use isupper() in a program in Python?


string = 'HOW ARE YOU?'
if string.islower() == True:
  print('All are uppercase letters.')
else:
  print('Contains lowercase letter.')
  
string = 'Hi HOW ARE YOU?'
if string.islower() == True:
  print('String does not contain lowercase letter.')
else:
  print('String Contains lowercase letter.')
 

Output:


All are uppercase letters.
String Contains lowercase letter.