Printed out more than three print statements


#1

Auto maker saying I have more than three print statements, but I have formatted it to what was asked. BTW I'm talking about lesson 8 of "A Day at the Supermarket".


Here is my code. Thanks in advance :grinning:

prices = {}
add_item = raw_input("Add item to store? (yes no): ").lower()
while add_item == "yes":
    item_name = raw_input("Item name: ")
    try:
        prices[item_name] = int(raw_input("What's the price? (if typed with cents it will appear again and take it with cents. e.g 1.5 and it will try again): "))
    except ValueError:
        prices[item_name] = float(raw_input("What's the price? "))
    add_item = raw_input("Add item to store? (yes no): ").lower()

stock = {}
while True:
    print ("Stock empty. Please fill it out")
    stock_name = raw_input("Item name: ")
    stock[stock_name] = int(raw_input("How many items? "))
    if raw_input("Finished filling in stock? (yes no) ") == "yes":
        break
stock_item = raw_input("+ or - items from stock? (yes no): ").lower()
while stock_item == "yes":
    if raw_input("Add(+) or subtract(-) from stock? ") == "+":
        stock_name = raw_input("Item name: ")
        stock[stock_name] += int(raw_input("How many items are you adding? "))
    elif raw_input("Add(+) or subtract(-) from stock? ") == "-":
        stock_name = raw_input("Item name: ")
        stock[stock_name] -= int(raw_input("How many items are you subtracting? "))
    stock_item = raw_input("+ or - item from stock? (yes no): ").lower()

for item in prices:
    print (item)
    print ("price: %s" % str(prices[item]))
    print ("stock: %s" % str(stock[item]))


#2

doing more then the exercise desires can result in error messages, i see a fourth print statement:

print ("Stock empty. Please fill it out")

the exercise validates there are only 3 print keywords, also this is python2, where you shouldn't use parentheses for print statements.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.