# # Does the provided password meet the requirements of at least 7 characters, # at least one uppercase letter, at least one lowercase letter, and at least # one digit. # # Parameters: # password: The password to evaluate # # Returns: # True if the password meets all of the requirements. False otherwise. # def passwordOK(password): # Check the length requirement if len(password) < 7: return False # Check that the password has an uppercase letter if password == password.lower(): return False # Check that the password has a lowercase letter in it has_lower = False for ch in "abcdefghijklmnopqrstuvwxyz": # for each lowercase letter if password.find(ch) >= 0: # if the current letter is in the password has_lower = True if has_lower == False: return False # Check that the password has a digit in it has_digit = False for ch in password: # for each character in the password if ch >= "0" and ch <= "9": has_digit = True return has_digit def main(): password = input("Enter a password to check: ") if passwordOK(password): print("That password meets all the requirements.") else: print("You can't use that password. You'll have to choose a different one.") main()