Password Strength Checker
What you're building
A PasswordChecker that evaluates a password against common rules and returns a score and a list of improvement hints.
Requirements
check(password) returns a dict:
{
"score": int, # 0β4 (one point per rule met)
"hints": list # rules that were NOT met
}
Rules (1 point each):
- At least 8 characters long
- Contains an uppercase letter
- Contains a digit
- Contains a special character (
!@#$%^&*())
pc = PasswordChecker()
pc.check("hi")
# {"score": 0, "hints": ["at least 8 characters", "uppercase letter", "digit", "special character"]}
pc.check("Secure1!")
# {"score": 4, "hints": []}
Stretch goals
- Penalise common passwords like
"password"or"123456". - Add a
strength_label()that maps score to"weak"/"fair"/"strong"/"very strong".
What this proves
String inspection, boolean flags, list building, and dict construction β building-block skills for any auth or security feature.
β‘ 50 XP
solution.pyRuns in your browser (Pyodide)
Loading editorβ¦
Tests4 to pass
weak password scores 0
strong password scores 4
missing digit noted in hints
short password flagged
Run your code to check these.