Your problem is in this line, as the traceback shows:

>  return reduce(lambda x,y:x*y, [data[row][i] for i in range(col, col+4)])
>
>
So the thing you have to think about is - what values can col be? The
answer is then in this line:

for col in range(len(data[row]))

And since each row of your data has 20 numbers in, col ranges between 0 and
19.

What happens when col is 19 and you try to do 'return reduce(lambda
x,y:x*y, [data[row][i] for i in range(col, col+4)])'? i will vary between
19 and 22, and so at some point you'll be trying to pick the 21st, 22nd and
23rd elements of a list of 20 numbers. Obviously you can't do that - so you
get a 'list index out of range'.

-- 
Robert K. Day
robert....@merton.oxon.org
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to