Best way to do this?
Jeff Epler
jepler at unpythonic.net
Sat Jan 17 18:26:26 EST 2004
More information about the Python-list mailing list
Sat Jan 17 18:26:26 EST 2004
- Previous message (by thread): Retrive unicode keys from the registry
- Next message (by thread): Best way to do this?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): Retrive unicode keys from the registry
- Next message (by thread): Best way to do this?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list