On Fri, Apr 1, 2011 at 12:52 PM, Karl <8213543ggxnvjx...@kabelmail.de>wrote:

>  Hello,
>
>
> one beginner question:
>
>
> aList = [0, 1, 2, 3, 4]
>
> bList = [2*i for i in aList]
>
> sum = 0
>
> for j in bList:
>
This iterates over the values in bList, not its indices.

>  sum = sum + bList[j]
>
So instead of adding bList[0] .. bList[4], consecutively, you're adding
bList[0] .. bList[8] skipping every other element - but there aren't that
many elements.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to