Alright, I am working on this for an assignment and I cannot seem to figure out where I went wrong...
My first problem, whenever I input the CC number, the only one it accepts is the last one in my text file...
My second problem, when it does accept a CC number and display the proper text in the code below, it doesn't break out of it properly...I tried adding breaks to random spots, but it doesn't seem to be working.
Any help would be appreciated. :)
selection = raw_input("Are you are returning customer? [Y/N] ")
while True:
if selection.upper() == "Y":
while True:
try:
ccNumberCheck = int(raw_input("Please enter the credit card number last used here: "))
if len(str(ccNumberCheck)) == 16:
ccFile = open("cat.txt", "r")
for line in ccFile:
items = line.split(",")
if str(ccNumberCheck) == items[2]:
title = items[0]
lastName = items[1]
ccNumber = items[2]
print "Welcome back, " + title + ". " + lastName + "!"
break
ccFile.close()
break
except ValueError:
print "Sorry, that is an incorrect value."