Help with python code

Wildman best_lay at yahoo.com
Tue Mar 29 18:51:50 EDT 2016


On Tue, 29 Mar 2016 21:19:05 +0000, Rob Gaddi wrote:

>> menu = input("Enter the type of pizza that you want to order from 1-5 \n")
>> while menu>5 or menu <=0:
>>     menu = input ("Enter the right number ")
>> pizza_cost = pizzatype[menu]

As it has already been pointed out, a Python list starts with an index
of 0.  Change the last line in the above code to this...

    pizza_cost = pizzatype[menu - 1]

Anywhere else that your code references a list index you may need to
make the same change.

-- 
<Wildman> GNU/Linux user #557453
May the Source be with you.



More information about the Python-list mailing list