[Tutor] For Loop question

Danny Laya danny_laya at yahoo.com
Thu Jun 26 15:27:05 CEST 2008

Hi I'm learning FOR loop now, very easy too learn. But I get confused to understand this code :
myList = [1,2,3,4]
for index in range(len(myList)):
    myList[index] += 1
print myList

And the response is:
[2, 3, 4, 5]

Can you explain me as a newbie, how that code works ??

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080626/3d0d3878/attachment.htm>

More information about the Tutor mailing list