+ 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 ( ):

1st Mar 2020, 6:46 AM
Syed Arsalan
Syed Arsalan - avatar
17 ответов
+ 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.
1st Mar 2020, 7:00 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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.
1st Mar 2020, 8:17 AM
John Wells
John Wells - avatar
+ 3
... you literally use int(meat_dish) or str(nihari) and compare the two, did you copy the code?
1st Mar 2020, 7:05 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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
1st Mar 2020, 7:58 AM
John Wells
John Wells - avatar
+ 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.
1st Mar 2020, 8:05 AM
John Wells
John Wells - avatar
+ 2
Either change the string to an integer the integer to a string.
1st Mar 2020, 7:02 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
No. Here is the correct code: if int(meat_dish) == nihari: # your code
1st Mar 2020, 7:14 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
Thanks 😊 it is working
1st Mar 2020, 8:02 AM
Syed Arsalan
Syed Arsalan - avatar
+ 1
I have made very little mistake
1st Mar 2020, 8:03 AM
Syed Arsalan
Syed Arsalan - avatar
0
So what i jave to do??
1st Mar 2020, 7:01 AM
Syed Arsalan
Syed Arsalan - avatar
0
Noo
1st Mar 2020, 7:06 AM
Syed Arsalan
Syed Arsalan - avatar
0
def prices(): total_price=meat_quantity*int(nihari) if meat_dish == nihari and nihari== int(nihari): print(meat_quantity*nihari) prices()
1st Mar 2020, 7:12 AM
Syed Arsalan
Syed Arsalan - avatar
0
Will it work
1st Mar 2020, 7:13 AM
Syed Arsalan
Syed Arsalan - avatar
0
It also doesn't work
1st Mar 2020, 7:20 AM
Syed Arsalan
Syed Arsalan - avatar
0
Ok
1st Mar 2020, 8:10 AM
Syed Arsalan
Syed Arsalan - avatar
0
Yess
1st Mar 2020, 8:19 AM
Syed Arsalan
Syed Arsalan - avatar
- 1
Please can you do it ??
1st Mar 2020, 7:03 AM
Syed Arsalan
Syed Arsalan - avatar