Password Strength Checker

Check password strength based on multiple criteria.

AdvancedPhase 6 - Category 5: Real-World Logic ProblemsExample 1 of 15
password-strength-checker.py
1# Take password
2password = input("Enter password: ")
3
4# Check criteria
5has_length = len(password) >= 8
6has_upper = any(char.isupper() for char in password)
7has_lower = any(char.islower() for char in password)
8has_digit = any(char.isdigit() for char in password)
9has_special = any(not char.isalnum() for char in password)
10
11# Calculate strength
12score = sum([has_length, has_upper, has_lower, has_digit, has_special])
13
14if score == 5:
15 print("Strong password")
16elif score >= 3:
17 print("Medium password")
18else:
19 print("Weak password")

Output

Enter password: MyPass123!
Strong password

Enter password: password
Weak password

What's going on

Check multiple password criteria.

Key Concepts:

Check length, case, digits, special chars
Count criteria met
Rate strength