Best way to do this?

Wil Schultz newz at rekon.org.NOSPAM
Sat Jan 17 20:40:19 EST 2004


Well, not quite that far yet but apparently there are a few different 
way's. Mine of course being the most primitive! ;)

Thank you both!

Wil
my 2¢
"When everything seems to be going well, you have obviously overlooked
something."


Jeff Epler wrote:
> def getpass(password, count=3):
> 	for i in range(count):
> 		p = raw_input("Password: ")
> 		if p == password: return 1
> 	return 0
> 
> No need to initialize count to 0 and use a while loop, use a "for" loop
> instead.  No need to initialize password above the loop (and if you had
> to, use None instead of "null"), and no need to set count to 3 when the
> correct password is entered---just use return or break.
> 
> Jeff
> 



More information about the Python-list mailing list