<div class="gmail_quote">On Tue, Jun 30, 2009 at 9:53 PM, Daniel Sato <span dir="ltr"><<a href="mailto:sato.photo@gmail.com">sato.photo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<snip> </blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I have been able to make the module quit after entering a password three times, but can't get it to quit right away after the correct one is entered. I know this is really basic, please forgive me. I have no programming experience and have just started going through these tutorials</blockquote>
<div><br>Let's take a quick look at your code: <br></div></div><br><div class="syntax"><div class="python" style="font-family: monospace;"><ol><li class="li1"><div class="de1">password = <span class="st0">"qwerty"</span></div>
</li><li class="li2"><div class="de2">guess = <span class="st0">"0"</span></div></li><li class="li1"><div class="de1">count = <span class="nu0">0</span></div></li><li class="li2"><div class="de2"><span class="kw1">while</span> count != <span class="nu0">3</span>:</div>
</li><li class="li1"><div class="de1"> guess = <span class="kw2">raw_input</span><span class="br0">(</span><span class="st0">"Enter your password: "</span><span class="br0">)</span></div></li><li class="li2">
<div class="de2"> guess = <span class="kw2">str</span><span class="br0">(</span>guess<span class="br0">)</span></div></li><li class="li1"><div class="de1"> <span class="kw1">if</span> guess != password</div>
</li><li class="li2"><div class="de2"> <span class="kw1">print</span> <span class="st0">"Access Denied"</span></div></li><li class="li1"><div class="de1"> count = count + <span class="nu0">1</span> </div>
</li><li class="li2"><div class="de2"> <span class="kw1">else</span>:</div></li><li class="li1"><div class="de1"> <span class="kw1">print</span> <span class="st0">"Password Confirmed"</span></div>
</li></ol>On line 4 you enter a while loop. What criteria stops the loop? <br><br>As an aside - with while loops it's better to use a < or > (or >= <=) comparison. Because what happens if something goes wrong inside your loop and count becomes 4? Your loop takes a LONG time to finish! Actually in python it probably won't ever finish. Also you should move line 9 either right after line 4 or right after line 11. When you're incrementing a value it's best to do it at the beginning or end of a loop. (and certainly never in between an if and else!)<br>
<br>So with this in mind, what could you do once it prints "Password confirmed" to make sure the loop ends?<br><br>HTH,<br>Wayne<br><br><br></div></div>