On Jun 6, 3:19 pm, "John Salerno" <[EMAIL PROTECTED]> wrote: > "Mensanator" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > On Jun 6, 1:44 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > > > "Mensanator" <[EMAIL PROTECTED]> wrote in message > > And since the OP foolishly > hardcoded his range bounds > > Hmm, I just love the arrogance of some people. I actually posted a response > to my own thread that asked about this situation of how best to make the > range, but it doesn't seem to have posted.
It wasn't meant to be arrogant. Just that you must be careful with zip() because it will not throw an exception if the two iterables are of different length (this behaviour is by design) but simply return tuples for the shorter of the iterables. Hardcoding the range bounds instead of setting them dynamically is a classic cause of this type of error. Obviously, you want the range to start with 8, but what should be the upper bound? The start plus the length of the other iterable keeping in mind that if length is 11, last index is 8+10 since counting starts at 0. So you want range(8,8+len(score_costs)) Using enumerate() means you don't have to figure this out and you'll never get an error or bad results that don't make an error. -- http://mail.python.org/mailman/listinfo/python-list