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 input2ch = input("Enter a character: ")34# Check character type5if 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 uppercaseislower(): checks if lowercaseisdigit(): checks if digitOtherwise, it's a special character
🔗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