Aug-01-2019, 01:37 PM
(This post was last modified: Aug-01-2019, 01:40 PM by ichabod801.)
My code gives me back all the names in the dictionary when I want it to only give back the name that corresponds with the pin. Any reason why and how I could fix it is appreciated. Thanks!
Here's my code:
Here's my code:
import time count=0 correct_pin = {"Peter":352, "james":123, "richard":321} while count<4: pin = int(input("What is your password: ")) if pin in correct_pin.values(): print ("Correct! You are now logged in, ") for key in correct_pin.keys(): print (key) time.sleep(1) print() print() print("Opening Codes") time.sleep(1) print("Please Wait...") print() time.sleep(3) g = open("Codes.txt","r") s = g.read() print(s) g.close() exit() break elif pin not in correct_pin.values() and count<=4: print('Wrong! Try again') count= count+1 if count<=4: print("You got it wrong too many times. Account locked!")