generate functionThu, 09 Feb 2023

Write a program that simulates checking a user's password. The user first enters a password, then enters a password confirmation. You need to handle the following situations: if the password entered by the user (for the first time) is shorter than 7 characters, the program displays Short if the password is long enough, but the password entered the second time does not match the first, the program displays Difference if this check is also successful, the program displays OK in Latin letters

def password_check(pw, pw_confirm): if len(pw) < 7: return 'Short' elif pw != pw_confirm: return 'Difference' else: return 'OK' pw = input() pw_confirm = input() print(password_check(pw, pw_confirm))

Questions about programming?Chat with your personal AI assistant