0

On the third and fourth test for Felipe's Taqueria (CS50P) the output seems correct to me, but apparently is wrong. This is the test's output: Could not find the following in the output: $14.00 Actual Output: $3.00 $6.00 $14.00 Add item:

And this is my code:

price_list = {"Baja Taco": 4.00,"Burrito": 7.50,"Bowl": 8.50,"Nachos": 11.00,"Quesadilla": 8.50,"Super Burrito": 8.50,"Super Quesadilla": 9.50,"Taco": 3.00,"Tortilla Salad": 8.00}

def main():
    order = []
    while True:
        try:
            items = input("Add item: \n").title()
            order.append(items)
            add_up(order)
        except EOFError:
            break
        except KeyError:
            pass

def add_up(order):
    values = []
    for item in order:
        price = price_list[item]
        values.append(price)
        result = float(sum(values))
        print("$", f"{result:.2f}",sep='')

main()

Also, if someone could advice about my style or if I could've done something more efficiently it would be appreciated.

1 Answer 1

1

The specification expects the output to be one number (the total) after each item is entered. This program will print a total for each item in the order every time an item is added to the order. Specifically, check50 is expecting the program to output $14.00 after tortilla salad is entered. This program outputs

$3.00
$6.00
$14.00
1
  • I moved the print function out of the loop and it works as expected, thanks!
    – Agus
    Commented Sep 13, 2022 at 23:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .