Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106000
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Help with python code |
| Date | 2016-03-29 22:19 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <nderbv$hnm$1@dont-email.me> (permalink) |
| References | <a4b1ac8d-bf43-4b1f-8e60-394d1a740dca@googlegroups.com> |
On 29/03/2016 22:00, okdk wrote:
> pizzatype = [3.50,4.20,5.20,5.80,5.60]
> drinktype = [0.90,0.80,0.90]
> topping = [0.50,0.50,0.50,0.50]
> total_cost = total_cost_cal(pizzatotal, drinktotal, topping_cost)
>
> print ("--------------------------------")
> print ("Calculating bill")
> print ("--------------------------------")
> print ("--------------------------------")
>
> print ("Thank You for ordering at Pizza Shed! ")
>
>
> Howeve, it doesnt seem to be working. It doesnt calculate the bill. I dont know what to do, as I'm less than average at this.
> it comes up as IndexError: list index out of range at line42
Those lists you define are indexed from 0, not 1 as you seem to assume.
(So you get an index error if choosing pizza type 5).
You might try inserting a dummy 0 at the start (so the rest are indexed
from 1), but better to change the logic.
Also total_cost_cal() is not defined anywhere. (And the user interface
is generally untidy with poor error checking, but this can be cleaned up
later.)
(I also found I was obliged to choose an extra topping. Suppose I don't
want one? There is no option for that. Perhaps you can use option 0 for
some of these, and that might help solve the indexing problem.)
--
Bartc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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