<html><div style='background-color:'><P>Hi Brian</P>
<P>Thanks for correcting me about the variable and reserved word differences (just for the record the problem is that my english is not so good, you see I'm from Bolivia so pardon my francôis :P)</P>
<P>About the code I posted let me stand for it because it sure works like a charm.</P>
<P>I tested and the Option 1 gives the message of "That has been difficult" stuff when you pass the 3 errors and still ask you for password.</P>
<P>The option 2 loops 3 times unless you put unicorn or whatever is the password and at the third time it gives the&nbsp;message and then increment the current_count once more to take you out of the while loop</P>
<P>Test it and let me know how it went, and also if I have a few problems with my writing please let me know as I will try to correct them</P>
<P>Regards</P>
<P>Alberto&nbsp;</P>
<P>&nbsp;</P>
<P>&gt;From: Brian van den Broek &lt;bvande@po-box.mcgill.ca&gt; &gt;To: Alberto Troiano &lt;albertito_g@hotmail.com&gt; &gt;CC: glaevsky@ECE.NEU.EDU, tutor@python.org &gt;Subject: Re: [Tutor] Cell Bio Newbie Here &gt;Date: Mon, 11 Apr 2005 16:45:55 -0400 &gt; &gt;Alberto Troiano said unto the world upon 2005-04-11 16:09: &gt;&gt;Hey Gary &gt;&gt; &gt;&gt;password="foobar" &gt;&gt; &gt;&gt;####### &gt;&gt; &gt;&gt;the variable password has to be here because you are referiencing &gt;&gt;before the assignment inside the while sentence. You can also set &gt;&gt;it to password="" and still will work because you have to tell (in &gt;&gt;this example) that password is a reserved word(variable) &gt; &gt;Hi Alberto, Gary, and all, &gt; &gt;Alberto, if I may, I think there are some problems in what you &gt;posted. (But, if you want to see some *really* troubled postings, &gt;just find some of my 
earliest attempts to answer on the tutor list!) &gt; &gt;I think it is important to keep the distinction between variables &gt;and &gt;reserved words clear. &gt; &gt;&gt;&gt;&gt;if = "Won't work as 'if' is a reserved word" &gt;Traceback ( File "&lt;interactive input&gt;", line 1 &gt; if = "Won't work as 'if' is a reserved word" &gt; ^ &gt;SyntaxError: invalid syntax &gt;&gt;&gt;&gt; &gt; &gt;"Reserved words" or "keywords" are the fixed words of the Python &gt;language itself. See Section 2.3.1 Keywords of the Language &gt;Reference. &gt; &gt;&gt;######## &gt;&gt; &gt;&gt;count=3 &gt;&gt;current_count=0 &gt;&gt; &gt;&gt;####### &gt;&gt; &gt;&gt;Here you have two options: &gt;&gt; &gt;&gt;Option 1: &gt;&gt; &gt;&gt; &gt;&gt;while password !="unicorn": &gt;&gt; if current_count&lt;count: &gt;&gt; password=raw_input("Password:") &gt;&gt; current_count=current_count+1 &gt;&gt; else: 
current_count=2 print "That must have &gt;&gt;been complicated" &gt;&gt; &gt;&gt;print "Welcome in" &gt;&gt; &gt;&gt;Add this line inside the "else" clause: current_count=2 ####This &gt;&gt;will make you have more chances and if you fail it will complain. &gt; &gt;That isn't going to solve the infinite looping problem in the case &gt;that password never is equal to 'unicorn' &gt; &gt;&gt;The problem is that current_count doesn't decrement in the loop, so &gt;&gt;let's say you fail 3 times the current_count will keep looping &gt;&gt;because its value is 3 and it won't change in your code. Also I &gt;&gt;think that if you're making an application to restrict the error to &gt;&gt;3 times you may want to finish the app to start over so in that &gt;&gt;case you may want to try option 2. &gt;&gt; &gt;&gt;####### &gt;&gt; &gt;&gt;Option 2: &gt;&gt; &gt;&gt;while password !="unicorn" and 
current_count &lt;= count: &gt;&gt; if current_count&lt;count: &gt;&gt; password=raw_input("Password:") &gt;&gt; current_count=current_count+1 &gt;&gt; else: current_count=current_count+1 &gt;&gt; print "That must have been complicated" if &gt;&gt;password="unicorn": print "Try again Later" &gt;&gt; else: print "Welcome in" &gt;&gt; &gt;&gt;Here you will lock your prog when the user fails 3 times and will &gt;&gt;print your line once and then will jump to Try Again later and it &gt;&gt;will finish &gt; &gt;I'm pretty sure there are some crossed wires here. :-) Maybe you &gt;intended the last two print statements to be swapped? But, either &gt;way, since Option 2 will never exit the while loop unless password &gt;does &gt;equal 'unicorn', the final else clause will never be reached. Or, so &gt;it seems to me. &gt; &gt;Last, I don't see why the first else block increments current_count. &gt; &gt;Best, &gt; &gt;Brian vdB &gt; &gt; </P></div></html>