Computer >> Computer tutorials >  >> Programming >> Python

How to check if a character is upper-case in Python?


To check if a character is upper-case, we can simply use isupper() function call on the said character. 

 example

print( 'Z'.isupper())
print( 'u'.isupper())

Output

True
False

We can also check it using range based if conditions. 

 example

def check_upper(c):
    if c >= 'A' and c <= 'Z':
        return True
    else:
        return False
print check_upper('A')
print check_upper('a')

Output

This will give us the output:

True
False