# How to calculate the total in the following program?

I have created a small program to practice what I learned in python.

for example, I have prices in a list, so I calculated the total by indexing the list. I’m not able to store it in a variable.

Are there any possible ways we could store it in a variable?

food_name = [ Chicken sandwich, bun, beef fry, Chicken balls]

for food_display in [’ Chicken sandwich 10\$ (A) , bun 2\$ (B), beef fry 12\$ ©, Chicken balls 5\$ (D)’]:
print(food_display)
Food_price = [10, 2, 12, 5]

order_entry = input("").upper()
Number_of_quantity = intinput(""))

if order_entry = ‘A’:
print(“Ordered:{}”.format({food_name[0]}), “Total:”, price[0] * food_quantity )

This is a similar example of my program.

Now how do I assign “price[0] * food_quantity” to a variable?

Any Volunteer would like to offer me a solution to this problem.
Your support would be highly appreciated!

Thank you!

Could you find a solution?? I see some syntax errors in your code, so it’s hard to understand what you want to do.

If you haven’t found a solution, I’d be glad to help

Let me know

I really appreciate it. However, i have re-write the code and found the solution for the problem.

1 Like