+ 1
I cannot make run this code
Error attribute https://code.sololearn.com/cvfaXhN4xnmN/?ref=app I need some help please
7 Answers
+ 1
Reda Zerghani
[] indicate list
{} indicate set / dictionary
() indicate tuple
what I've used in code is dictionary
+ 3
order.replace([0], "Coke") #error list has no function replace.
Use like :
order[0] = "Coke"
Similar for others...
And in
total_price += price #error here total_price is integer and price is a string, you can't add both..
price can't give price of items here.. You need to think about logic again..
Again you need a loop, and depends upon string from menu, add price to total. Make use of respected price from first declared 5 variables..
+ 3
Snehil Pandey The future is now thanks to science[In a break] Jayakrishnađźđł thank to you all !!
+ 2
Jayakrishnađźđł thank you, for tour insight
+ 1
A bit weird thing but I've tried what I've understood:
https://code.sololearn.com/c2Oojt52y81O/?ref=app
+ 1
Snehil Pandey thank you to you too can you explain why do you use the braket in the menu variable ? In which lésions of phyt Sl is it ?
+ 1
You have done many mistakes,
1st one,replace method is used to replace a specific word from a string. Here, you want to replace or rewrite the full string. So use the = operator.
2nd one, you have written the condition manually, it's better to use a loop to do that.
3rd one, the price variable is a string since you iterate the order. So you cannot add a string inside an int variable.
4th one, percent operator % is used to find the remainder of a value not for getting the percentage. so you have to do it manually by dividing 100
You can use a dictionary to save the price of every item without declaring the menu and check the condition using the loop. Then get the total price from the order.
Editing your attempt:
https://code.sololearn.com/cYFr0ZvM3H9n/?ref=app