[Tutor] need futher explaining

Dale Pearl dale.pearl at gmail.com
Mon Aug 6 09:13:05 CEST 2007


I'm reading Beginning Python - From Novice to Professional by Magnus Lie
Hetland (an Apress book) and there is a code example that I need further
explaining on to fully grasp.
There is a section with samle code of:
 names = ['anne', 'beth', 'george', 'damon']
ages = [12, 45, 32, 102]
for i in range(len(names)):
print names[i], 'is', ages[i], 'years old'

now all of it makes sense to me except for the line for i in
range(len(names)):
the len statement calculates the number of characters I'm not quite
understanding the magic here.
forgive my stupidity this programming stuff is new to me but if someone
could explain to me how this single line works it would be greatly
appreciated.

By the way this is a great book well worth the investment to anyone's
library who is trying to learn Python.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070806/a50168a9/attachment-0001.htm 


More information about the Tutor mailing list