<div dir="ltr">Hi all,<br><br>After a rather long (and unfortunate) break from tinkering with Python, I am back at it.&nbsp; 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>&gt;&gt;&gt; L = [1, 2, 3, 4, 5]<br>&gt;&gt;&gt; for i in range(len(L)):<br>...&nbsp;&nbsp;&nbsp;&nbsp; L[1] += 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # this is a typo I made - should have been L[i], not L[1].<br>...<br>&gt;&gt;&gt; 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 &#39;7&#39;, where the &#39;2&#39; should be.&nbsp; My best guess is that L[1] is treated as the index of the value &#39;2&#39;.&nbsp; 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>