Re: [Tutor] a simple password program

Magnus Lycka magnus at thinkware.se
Thu Mar 11 17:07:12 EST 2004


Nick Noda wrote: 
> hey guys, 

Hello Nick, and welcome. 

[code snipped]  
>     i can get it to say "Welcome inside." if the pass is correct, but if the pass is guessed wrong three times it just keeps looping "Too complicated, huh?" i was wondering if it is supposed to do that or if there is a way that i can get it to say it once then quit. any help i would jump up and down for. 

You are obviously supposed to be able to make the program do 
whatever you want. There are at least two solutions that come 
to mind. You might want to look up what the "break" statement 
does. You might also consider turning the loop and if conditions 
around... 

Just as well as you can loop while not right password and do 
something particular after three guesses, you might instead 
loop three times, and do something special when the guess is 
right. (Such as leave the loop, read about break.) 

There are many ways to skin a cat. If you want the program to 
exit after three wrong guesses you can just write 

    import sys; sys.exit() 

after 'print "Too complicated, huh?"' 

For a password program that actually lets you stop worrying 
about administering passwords :), check out 
http://www.thinkware.se/cgi-bin/thinki.cgi/PopAuthPy 

--  
Magnus Lycka, Thinkware AB 
Alvans vag 99, SE-907 50 UMEA, SWEDEN 
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65 
http://www.thinkware.se/  mailto:magnus at thinkware.se 




More information about the Tutor mailing list