Password Validator
Validate password strength.
BeginnerPhase 6 - Category 5: Real-World Logic ProblemsExample 13 of 15
password-validator.py
1# Take password2password = input("Enter password: ")34# Validate5has_upper = any(c.isupper() for c in password)6has_lower = any(c.islower() for c in password)7has_digit = any(c.isdigit() for c in password)8has_special = any(c in "!@#$%^&*" for c in password)9length_ok = len(password) >= 81011if length_ok and has_upper and has_lower and has_digit and has_special:12 print("Strong password")13elif length_ok and (has_upper or has_lower) and has_digit:14 print("Medium password")15else:16 print("Weak password")
Output
Enter password: MyPass123! Strong password
What's going on
Check multiple conditions.
Key Concepts:
Check various character types
Validate length
Classify strength
🔗Related Content
- 📖
Phase 6 - Learn Concepts
Review Phase 6 concepts and explanations
- 📝
Phase 6 - Quiz
Test your Phase 6 understanding with quiz questions
- 💻
Phase 6 - All Practice Problems
Explore all practice problems for Phase 6
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum