Logic Building
# Take password
password = input("Enter password: ")
# Validate
has_upper = any(c.isupper() for c in password)
has_lower = any(c.islower() for c in password)
has_digit = any(c.isdigit() for c in password)
has_special = any(c in "!@#$%^&*" for c in password)
length_ok = len(password) >= 8
if length_ok and has_upper and has_lower and has_digit and has_special:
print("Strong password")
elif length_ok and (has_upper or has_lower) and has_digit:
print("Medium password")
else:
print("Weak password")Output
Enter password: MyPass123! Strong password
Check multiple conditions.
Key Concepts:
- Check various character types
- Validate length
- Classify strength