Founding Batch Offer ยท HLD ยท LLD ยท System Design at โ‚น799 until 30 Nov

Check Character Type

Identify uppercase text, lowercase text, digits, or special input with Python. Students learn the order and limits of isupper, islower, and isdigit checks.

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

In this one

  • Use character classification methods
  • Understand whole-string tests
  • Keep branch priority

How it works

  1. 1

    Read the response without changing case.

  2. 2

    Try isupper, islower, then isdigit.

  3. 3

    Print the first matching label or the fallback.

Edge cases

What does an empty response produce?

What does an empty response produce?

All three tests are false, so the final label is Special character.

Is A1 uppercase here?

Is A1 uppercase here?

Yes. Its cased letters are uppercase; the digit does not make isupper false.

What's going on

This classifier calls string methods rather than comparing numeric character codes. The first successful test decides the label, beginning with isupper and then islower.

Input A reaches Uppercase, 5 reaches Digit, and @ reaches Special character. These methods inspect the whole response, not just its first character. For example, ABC is uppercase too, so the prompt alone does not enforce one-character input.

What does an empty response produce? All three tests are false, so the final label is Special character.

Is A1 uppercase here? Yes. Its cased letters are uppercase; the digit does not make isupper false.

Quiz

Tap an option. The answer stays hidden until you pick.

Question 1

Which method checks digit characters?

Pick an answer to check it.

Question 2

What does an empty response produce?

Pick an answer to check it.

Questions people ask

What does an empty response produce?

All three tests are false, so the final label is Special character.

Is A1 uppercase here?

Yes. Its cased letters are uppercase; the digit does not make isupper false.

Which method checks digit characters?

isdigit.