Check Character Type

Take a character and check whether it's uppercase, lowercase, a digit, or a special character.

BeginnerPhase 1 - Level 1: Simple ConditionsExample 10 of 10
check-character-type.py
1# Take a character as input
2ch = input("Enter a character: ")
3
4# Check character type
5if ch.isupper():
6 print("Uppercase")
7elif ch.islower():
8 print("Lowercase")
9elif ch.isdigit():
10 print("Digit")
11else:
12 print("Special character")

Output

Enter a character: A
Uppercase

Enter a character: a
Lowercase

Enter a character: 5
Digit

Enter a character: @
Special character

What's going on

Use string methods to check character type.

Key Concepts:

isupper(): checks if uppercase
islower(): checks if lowercase
isdigit(): checks if digit
Otherwise, it's a special character