I'm working on a hw assignment, and my if statement isn't working the way it's intended.

This is an ATM machine project. I've already gotten the program to read the csv file and stored it into a dictionary with the pin number as the key.

What I can't get it to do is find the pin number in my getUser() function. Below is the code and under that is the IDLE result. Please help!

d = {}
def startUp(fname):
        acct_file = open(fname,'r')
        for line in acct_file:
            (key,first,last,balance) = line.split(',')
            d[int(key)] = [last,first,float(balance)]
        print('Cannot get to the file')

def getUser():
    user_pin = int(input('What is your pin number? '))
    if user_pin in d.keys():
        return (user_pin,first,True)
        print('Incorrect Pin')
        return (None,None,False)

IDLE result: What is your pin number? 9967 this returns nothing

  • $\begingroup$ It returns nothing, but that pin number is in the file. $\endgroup$ – Dennis Kim Mar 5 '19 at 22:05
  • $\begingroup$ Hi Dennis! Unfortunately, this site is mostly for theoretical computer science; practical programming issues, like this one, will get better answers on StackOverflow. $\endgroup$ – Draconis Mar 5 '19 at 22:17
  • $\begingroup$ Oh got it. Thanks, @Draconis! $\endgroup$ – Dennis Kim Mar 5 '19 at 22:21

Browse other questions tagged or ask your own question.