# Check a password entered by the user and report whether or not it is good # Read the password from the user password = input("Enter a password: ") # Check the length of the password if len(password) >= 7: length_ok = True else: length_ok = False # Check that the password has an upper case letter # If the password is equal to the password with all of the letters converted # to lower case then there were no upper case letters to convert if password == password.lower(): uppercase_ok = False else: uppercase_ok = True # Check that the password has a lower case letter if password == password.upper(): lowercase_ok = False else: lowercase_ok = True # Check if the password contains a digit digit_ok = False for digit in "0123456789": if password.find(digit) >= 0: digit_ok = True # Report the result if length_ok and uppercase_ok and lowercase_ok and digit_ok: print("That's a good password.") else: print("That password didn't meet one of the rules.")