+ 1

Getting Invalid syntax for the line4: bill = 0 What is wrong with the code?

main( order = "Pizza Cheeseburger Water Popcorn" bill = 0 menu = {"Nachos":6.00, "Pizza":6.00, "Cheeseburger":1, "Water": 4, "Coke":5} for i in order: if i in menu: bill += menu[i] else: bill += 5 tax = (bill*7)/100 bill += tax return bill )

4th Jul 2022, 3:40 AM
Ashok Ighe
Ashok Ighe - avatar
2 Respostas
+ 3
Ashok Ighe , there are some issues in the code. if you wanted to run the code in the code coach in community section, you should fix these issues: (1) remove main and the related parenthesis ( ... ) (2) adapt the indentation after step (1) (3) do not use hard coded input, use input() instead (4) as already mentioned from Cristian Baeza Jimenez , the input string has to be split to individual words. this will result in a list of words (5) the price for the cheeseburger is 10 not 1 => all the rest should bd ok
4th Jul 2022, 2:26 PM
Lothar
Lothar - avatar
+ 2
There are some details; a) if you use return then you need the def keyword b) order is a string so to get each ingredient the function split() is needed
4th Jul 2022, 6:04 AM
Cristian Baeza Jimenez
Cristian Baeza Jimenez - avatar