Don't worry about it. No hard feelings. jeje ;-)
I notice about the == and != at the end after I posted it. Sorry about it.
And yes, your piece of code is more efficient and does the same so I think that's it for who asked, which I may say hasn't posted back.
Thanks for the reply
Regards
Alberto
![]()
Gaucho
>From: Brian van den Broek <[EMAIL PROTECTED]> >To: Alberto Troiano <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] Cell Bio Newbie Here >Date: Mon, 11 Apr 2005 19:11:50 -0400 > >Alberto Troiano said unto the world upon 2005-04-11 17:43: >>Hi Brian >> >>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) > > >Hi Alberto, > > >I wouldn't have known you felt you had difficulties in English had >you >not said so. :-) > >>About the code I posted let me stand for it because it sure works >>like a charm. >> >>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. >> >>The option 2 loops 3 times unless you put unicorn or whatever is >>the password and at the third time it gives the message and then >>increment the current_count once more to take you out of the while >>loop >> >>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 > >You are absolutely right that your `Option 2' code does exit the >loop. >I somehow missed that the while condition had an `and' in it :-[ My >apologies. > >Your second post said you intended the final if clause to be: >if password=="unicorn": > # etc > >I've changed it to >if password != "unicorn": > #
etc > >and get what I would think is correct behaviour. > >So, it now reads: > >password = None # necessary pre-setting of names >current_count = 0 >count = 3 > >while password != "unicorn" and current_count <= count: > if current_count < count: > password=raw_input("Password:") > current_count=current_count+1 > else: > current_count=current_count+1 > print "That must have been complicated" >if password!="unicorn": > print "Try again Later" >else: > print "Welcome in" > > >I would suggest that it be done like this, though: > ># pre-sets as before go here > >while password != "unicorn": > if current_count < count: > password = raw_input("Password:") > if password=='unicorn': > print 'Welcome in' > else: > print "That must have been complicated" > print "Try again Later" >
break > current_count += 1 > >This pushes all of the actions consequent on the password into the >password fetching loop and uses just a single incrementing line. > > >Anyway, once again, sorry for misreading and mis-correcting you. > >Best, > >Brian vdB > >
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor