Python password

Asked 2 years ago, Updated 2 years ago, 47 views

Enter your password and save it in advance. Maximum number of password entries: 3 If the password is correct, you will be logged in If it's wrong, "Type it again." If you enter it 3 times and you get it wrong, it should be printed as 'Login Failed!' and then shut down. You can enter it three times, but even if you get it wrong, it only says "Login".

i = 0
while i < 3:
    ▽ input input ("Password :").
    password = "iloveyou"
    if input == "iloveyou":
        Print ("log in!")
        break
    elif i > 3:
        Print, " failed logins! More than the number! ")
        i += 1
    else:
        Print ("Please enter the password again.").
        i += 1


python password

2022-09-20 17:06

1 Answers

The original code is to assign a password to password and to verify that password exists. You need to check if the input is the same as password.

i = 0
while i < 3:
    ▽ input input ("Password :").
    password = "iloveyou"
    if input == password:
        Print ("log in!")
        break
    elif i > 3:
        Print, " failed logins! More than the number! ")
        i += 1
    else:
        Print ("Please enter the password again.").
        i += 1


2022-09-20 17:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.