Check Alphabet Range
Take an alphabet character and check if it lies between 'a' and 'm' or 'n' and 'z'.
IntermediatePhase 1 - Level 2: Nested If & Multiple ConditionsExample 8 of 10
check-alphabet-range.py
1# Take character2ch = input("Enter a character: ").lower()34# Check range5if ch.isalpha():6 if 'a' <= ch <= 'm':7 print("Character is between 'a' and 'm'")8 elif 'n' <= ch <= 'z':9 print("Character is between 'n' and 'z'")10else:11 print("Not an alphabet")
Output
Enter a character: f Character is between 'a' and 'm' Enter a character: t Character is between 'n' and 'z'
What's going on
Use character comparison to check ranges.
Key Concepts:
Convert to lowercase for consistency
Check if between 'a' and 'm'
Check if between 'n' and 'z'
Use <= for range checks
🔗Related Content
- 📖
Phase 1 - Learn Concepts
Review Phase 1 concepts and explanations
- 📝
Phase 1 - Quiz
Test your Phase 1 understanding with quiz questions
- 💻
Phase 1 - All Practice Problems
Explore all practice problems for Phase 1
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum