newbie question
Karl
8213543GGXNVJXACA at kabelmail.de
Fri Apr 1 15:52:24 EDT 2011
Hello,
one beginner question:
aList = [0, 1, 2, 3, 4]
bList = [2*i for i in aList]
sum = 0
for j in bList:
sum = sum + bList[j]
print j
0
2
4
IndexError: 'list index out of range'
Why is j in the second run 2 and not 1 in the for-loop?? I think j is a
control variable with 0, 1, 2, 3, ...
Thanks!
Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110401/e1511806/attachment.html>
More information about the Python-list
mailing list