Logic Building
# Take password
password = input("Enter password: ")
# Check criteria
has_length = len(password) >= 8
has_upper = any(char.isupper() for char in password)
has_lower = any(char.islower() for char in password)
has_digit = any(char.isdigit() for char in password)
has_special = any(not char.isalnum() for char in password)
# Calculate strength
score = sum([has_length, has_upper, has_lower, has_digit, has_special])
if score == 5:
print("Strong password")
elif score >= 3:
print("Medium password")
else:
print("Weak password")Output
Enter password: MyPass123! Strong password Enter password: password Weak password
Check multiple password criteria.
Key Concepts:
- Check length, case, digits, special chars
- Count criteria met
- Rate strength