+ 1
What mistake i have done in python code? Because i want to create a small menu and i want to add prices of dishes so what i do??
https://code.sololearn.com/c9addhSd25Mv/?ref=app I have created mistake after def prices ( ):
17 Answers
+ 5
Next time please mentioned the error code as well, because it is hard to test codes where there are too many inputs.
Anyway, the problem is probably because you are comparing two different data types in line 48. You can't compare integers to strings.
+ 4
You will want to add with error message: sorry we have not this dish.
meat_dish = "none"
This will make the value valid in prices. Do similar for drinks_fav and juice_glass errors.
+ 3
... you literally use int(meat_dish) or str(nihari) and compare the two, did you copy the code?
+ 3
I updated your code for one meat. Removed the space in mutton. Ran with this input enter to the prompt:
john
nihari
orange
coffee
3
3
3
https://code.sololearn.com/crxt4Uq9BprI
+ 3
This code will be simpler using a dictionary (likely in a future lesson) as you can store the price with the string. You will not need to test each value, instead lookup the string to get the price.
+ 2
Either change the string to an integer the integer to a string.
+ 2
No. Here is the correct code:
if int(meat_dish) == nihari:
# your code
+ 1
Thanks 😊 it is working
+ 1
I have made very little mistake
0
So what i jave to do??
0
Noo
0
def prices():
total_price=meat_quantity*int(nihari)
if meat_dish == nihari and nihari== int(nihari):
print(meat_quantity*nihari)
prices()
0
Will it work
0
It also doesn't work
0
Ok
0
Yess
- 1
Please can you do it ??