I was working on the code in the 6th Chapter. The code works fine for the 4 options on the menu but when I Input 5(Quit), I get an "IndexError: list index out of range" error.
Moreover, I do not see the transactions.txt file being created in the directory my python codes are in.
I am running Python 3.3.2
Following is the code:
from transactions import * import promotion import starbuzz items = ["DONUT","LATTE","FILTER","MUFFIN"] prices = [1.50,2.0,1.80,1.20] running = True while running: option = 1 for choice in items: print(str(option)+"."+choice) option = option + 1 print(str(option)+".Quit") choice = int(input("Choose an option: ")) if choice == option: running = False else: credit_card = input("Credit card number: ") price = promotion.discount(prices[choice-1]) if input("Starbuzz discount card? ") == 'Y': price = starbuzz.discount(price) save_transaction(price,credit_card,items[choice-1])