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()
The isupper() method doesn't take any parameters.The function will check only alphabet characters no numbers, symbols, and spaces are checked.
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 |
string = 'PYTHON PROGRAMMING'
print(string.isupper())
string = 'PYTHON123 PROGRAMMING345'
print(string.isupper())
string = 'Hi PYTHON'
print(string.isupper())
Output:
True True False
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.