&gt; they find the &quot;while&quot; logic to be unintuitive<br><br>I&#39;ve found that a good way to explain &#39;while&#39; is to consider it as an &#39;if&#39; statement that repeats.&nbsp; Kids grasp simple conditionals fairly easily.&nbsp; I would sometimes hear them talk about &#39;if loops&#39; when they were actually trying to discuss conditional statements, and I would say to them hey look, there&#39;s no such THING as an &#39;if loop&#39;!&nbsp; But then it occurred to me - well, that&#39;s what a while statement is!&nbsp; So, let&#39;s just take a simple conditional, change the &#39;if&#39; to &#39;while&#39;, and there you have a loop!&nbsp; Only problem, it will keep repeating forever, so now we have to consider ways to get it to stop.
<br><br>Speaking from my own learning experiences, &#39;while True&#39; initially seemed awkward, probably for the same reason &#39;if True&#39; would - why bother?&nbsp; But at this point I actually do like the &#39;while True&#39; structure.&nbsp; 
<br><br>- Michel Paul<br><br><div class="gmail_quote">On Dec 12, 2007 3:01 AM, Brian Blais &lt;<a href="mailto:bblais@bryant.edu">bblais@bryant.edu</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div><div>On Dec 11, 2007, at Dec 11:11:11 PM, Terry Reedy wrote:</div><br><blockquote type="cite"><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;">&quot;Steven D&#39;Aprano&quot; &lt;
<a href="mailto:steve@REMOVE-THIS-cybersource.com.au" target="_blank">steve@REMOVE-THIS-cybersource.com.au</a>&gt; wrote in message<span>&nbsp;</span></div><div style="margin: 0px;"><a href="news:13lts6gb9t2j350@corp.supernews.com" target="_blank">
news:13lts6gb9t2j350@corp.supernews.com</a>...</div><div style="margin: 0px;">||</div><div style="margin: 0px;">| But loops that run at least once is a basic element of algorithms.</div><div style="margin: 0px;">| Perhaps not as common as the zero or more times of the while loop, but
</div><div style="margin: 0px;">| still fundamental. It is a shame it has to be faked using:</div><div style="margin: 0px;">|</div><div style="margin: 0px;">| while True: # force the first iteration to always run</div><div style="margin: 0px;">
|<span>&nbsp; &nbsp; </span>process</div><div style="margin: 0px;">|<span>&nbsp; &nbsp; </span>if condition: break</div><div style="margin: 0px;">|</div><div style="margin: 0px;">| Ugly and misleading.</div><div style="margin: 0px; min-height: 14px;">
<br></div><div style="margin: 0px;">I disagree.<span>&nbsp; </span>Nothing is being faked.<span>&nbsp; </span>The generic loop is</div><div style="margin: 0px; min-height: 14px;"><br></div><div style="margin: 0px;">while True:</div>
<div style="margin: 0px;"><span>&nbsp; &nbsp; </span>pre_process</div><div style="margin: 0px;"><span>&nbsp; &nbsp; </span>if condition: break</div><div style="margin: 0px;"><span>&nbsp; &nbsp; </span>post_process</div><div style="margin: 0px; min-height: 14px;">
<br></div></blockquote><div><br></div><div>I find that when teaching beginning programmers, they usually think in &quot;until&quot; terms, and not &quot;while&quot; terms.</div><div><br></div><div>do:</div><div>&nbsp;&nbsp; &nbsp;Forward()
</div><div>until Touched()</div><div><br></div><div>and I have to explain to them that Python doesn&#39;t have &quot;until&quot;, and that the logic for while is exactly the opposite:</div><div><br></div><div>while not Touched():
</div><div>&nbsp;&nbsp; &nbsp;Forward()</div><div><br></div><div>they find the &quot;while&quot; logic to be unintuitive, and I often find myself feeling the same way: crafting it with the until logic, and then reversing it. &nbsp;Perhaps I should do as above, and do:
</div><div><br></div><div>while True:</div><div>&nbsp;&nbsp; &nbsp;Forward()</div><div>&nbsp;&nbsp; &nbsp;if Touched(): break</div><div><br></div><div>but somehow that feels wrong to me, like bypassing the point of the while: all that power to check for conditions, and you just use it to check True, and then use a break inside. &nbsp;It&#39;s readable, I guess, but not a programming construct I am immediately drawn to.
</div><div><br></div><div><br></div><div><span style="white-space: pre;">                                </span>Brian Blais<br></div><div><br></div><div><br></div></div><div><span style="border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Monaco; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<div>--&nbsp;</div><div>Brian Blais</div><div><a href="mailto:bblais@bryant.edu" target="_blank">bblais@bryant.edu</a></div><div><a href="http://web.bryant.edu/%7Ebblais" target="_blank">http://web.bryant.edu/~bblais</a></div>
<div><br></div><br></span> </div><br></div><br>_______________________________________________<br>Edu-sig mailing list<br><a href="mailto:Edu-sig@python.org">Edu-sig@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/edu-sig" target="_blank">
http://mail.python.org/mailman/listinfo/edu-sig</a><br><br></blockquote></div><br>