Check a lowercase character

EasyIf-Else Programs · 24 of 64

Write a Python program to check whether a character is lowercase.

Advertisement
Input
"c", "Q"
Output
c True
Q False

Approach

  1. Use islower(), or compare with the range “a” to “z”.

Solution

Python
for ch in ["c", "Q"]:    if "a" <= ch <= "z":        print(ch, True)    else:        print(ch, False)
Output
c True
Q False

Line by line

Line 2

Characters compare by their Unicode order, so a chained comparison checks the a-z range. ch.islower() works too and also handles non-English letters.

Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More if-else programs

← All 64 If-Else Programs