First, you might want to change how the pizza names and prices are presented. Since you get user input as integer, I would suggest using list of tuples:
pizzas_with_prices = [('Tandoori chicken', 8.5), ('Prawn', 8.5) ..., ('Mediterraneo', 13.5)]
then you can loop over your pizza
list (which could be better named as selected_pizzas
or so):
total_price = 0
for selected in selected_pizzas:
total_price += pizzas_with_prices[selected][1]
print total_price
Also, couple of suggestions to improve the code:
For the first code block, you can get rid of the goodpizza_number
number_of_pizzas = 0
while 0 < number_of_pizzas <= 5:
try:
number_of_pizzas = int(input("How many Pizzas do you want? (MAX 5): "))
except ValueError:
print("Not a number, try again")
On the second block, as suggested, you could use list of tuples and use enumerate
pizzas_with_prices = [('Tandoori chicken', 8.5), ('Prawn', 8.5) ..., ('Mediterraneo', 13.5)]
for index, pizza in enumerate(pizzas_with_prices):
print("%d %s: $%s" % (index, pizza[0], pizza[1]))