<div dir="ltr">Hi all,<br><br>After a rather long (and unfortunate) break from tinkering with Python, I am back at it. I am working through the book Learning Python (based on 2.2/2.3 - I use 2.5), and in the chapter on while/for loops, ran across the following example:<br>
<br>>>> L = [1, 2, 3, 4, 5]<br>>>> for i in range(len(L)):<br>... L[1] += 1 # this is a typo I made - should have been L[i], not L[1].<br>...<br>>>> L<br>[1, 7, 3, 4, 5]<br>
<br>I did correct my typo, but what I do not understand is how range arrived at a '7', where the '2' should be. My best guess is that L[1] is treated as the index of the value '2'. I hope that learning how my error affected the result will help me grasp the concept a little better.<br>
<br>Thanks!<br>Don<br>-- <br>D.C. Parris<br>Minister, Journalist, Free Software Advocate<br><a href="https://www.xing.com/profile/Don_Parris">https://www.xing.com/profile/Don_Parris</a><br><a href="http://www.linkedin.com/in/dcparris">http://www.linkedin.com/in/dcparris</a><br>
<a href="mailto:sip%3Adcparris@ekiga.net">sip:dcparris@ekiga.net</a><br>
</div>