0

Python 3 coding to get user to input a password

Password_attempts = 3 password = “hello” password_left = password_attempts inputed_password = “none” while inputed_password != password and password_attempts : password = input(“enter password: “) if inputed password == password: print(“password is correct”) else: passwords_left -= 1 print(“Incorrect! %d attempts left.” % passwords_left)

7th May 2018, 10:49 PM
Janice N Pierce
Janice N Pierce - avatar
1 Odpowiedź
0
password_attempts = 3 password = "hello" while True: inputed_password = input("enter password: ") if len(inputed_password) == 0: continue if inputed_password == password: print("password is correct") break if inputed_password != password: password_attempts -= 1 print("incorrect attempts left: ", password_attempts) if password_attempts == 0: print("out of tries") break
19th May 2022, 7:01 PM
Weronika Pucek
Weronika Pucek - avatar