Check a lowercase character
Write a Python program to check whether a character is lowercase.
"c", "Q"
c True Q False
Approach
- Use
islower(), or compare with the range “a” to “z”.
Solution
for ch in ["c", "Q"]: if "a" <= ch <= "z": print(ch, True) else: print(ch, False)c True Q False
Line by line
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.
Learn the concept
New to this topic? Read the lesson, then come back.