problems
problems copied to clipboard
CS50P Problem Set 3 - taqueria - check50 does not catch missing reprompt for item not in the menu
Preconditions
- Have a
taqueria.py
, which prints "Total: ..." when user enters item not in the menu:
CONST_USER_PROMPT = "Item: "
CONST_MENU = {
"Baja Taco": 4.25,
"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() -> None:
total = 0
while True:
try:
order = input(CONST_USER_PROMPT).strip()
total += CONST_MENU.get(order.title(), 0)
print(f"Total: ${total:.2f}")
except EOFError:
print()
break
if __name__ == "__main__":
main()
Steps to reproduce:
-
Run
python taqueria.py
-
Enter the following items:
-
Burrito
-
not in the menu
-
burger
-
-
Output:
-
Run
check50 cs50/problems/2022/python/taqueria
Expected result:
-
check50
should fail the validation -
The description for the assignment contains the following:
After each inputted item, display the total cost of all items inputted thus far, prefixed with a dollar sign ($) and formatted to two decimal places. Treat the user’s input case insensitively. Ignore any input that isn’t an item.
-
Demo showcases the reprompt on incorrect input:
-
The "How to test" section has the following:
Run your program with python taqueria.py. Type Burger and press Enter. Your program should reprompt the user.
Actual result:
-
check50
passes the code - test
:) input of "burger" results in reprompt
passes validation