Due 11/4 at 11:59pm
Ever notice how websites tell you if your password is “weak,” “medium,” or “strong”? In this project, you will write a program that analyzes passwords and rates their strength based on multiple criteria.
Your program must meet the following specifications:
check_password_strength that takes a password as input and returns a strength rating!@#$%^&*)For example:
You can check if a string contains uppercase, lowercase, digits, or other characters by looping through each character:
password = "MyPassword123!"
# Check if string contains uppercase
has_upper = False
for char in password:
if char.isupper():
has_upper = True
print(has_upper) # True
The isupper(), islower(), and isdigit() methods check a single character.
def check_password_strength(password):
"""Analyze password strength and return a rating."""
# TODO: Check each criterion and count how many are met
# TODO: Determine strength rating based on count
# TODO: Return the rating
password = input("Enter a password: ")
# TODO: Call check_password_strength()
# TODO: Print the rating and which criteria were met/not met