Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106015

Re: Help with python code

From Wildman <best_lay@yahoo.com>
Subject Re: Help with python code
Newsgroups comp.lang.python
References <a4b1ac8d-bf43-4b1f-8e60-394d1a740dca@googlegroups.com> <nderg8$i83$1@dont-email.me>
Organization Wildman Productions
Message-ID <MoCdnSzyu6GbmmbLnZ2dnUU7-bWdnZ2d@giganews.com> (permalink)
Date 2016-03-29 17:51 -0500

Show all headers | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Help with python code okdk <nevinadias3@gmail.com> - 2016-03-29 14:00 -0700
  Re: Help with python code BartC <bc@freeuk.com> - 2016-03-29 22:19 +0100
  Re: Help with python code Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-03-29 21:19 +0000
    Re: Help with python code Wildman <best_lay@yahoo.com> - 2016-03-29 17:51 -0500
  Re: Help with python code Yum Di <nevinadias3@gmail.com> - 2016-03-29 14:32 -0700
    Re: Help with python code Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-03-29 21:37 +0000

csiph-web