What do i need to add | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
21st Apr 2022, 8:10 AM
Aisy Danish Mohd Nazry
Aisy Danish Mohd Nazry - avatar
4 Answers
+ 1
You are testing the entire array in your if statement instead of the current element. Use i not y.
21st Apr 2022, 8:19 AM
John Wells
John Wells - avatar
0
Maybe you are supposed to only print the tax and not tax + price? What exactly is the task?
21st Apr 2022, 8:17 AM
Lisa
Lisa - avatar
0
Firstly you should put the value "sum=0" outside of the for loop because while inside the for loop the sum is always reset. Also use i instead of y as John Wells said. So here is the code: x = input() y = x.split(" ") sum=0 for i in y: if "Pizza" in i: sum += 6 elif "Nachos" in i: sum += 6 elif "Cheeseburger" in i: sum += 10 elif "Water" in i: sum += 4 else: sum += 5 tax = (sum*107)/100 print(tax)
21st Apr 2022, 8:54 AM
Commander
0
Thank you very much guys
21st Apr 2022, 9:19 AM
Aisy Danish Mohd Nazry
Aisy Danish Mohd Nazry - avatar