help on ultra newbie program please

Peter Hansen peter at engcorp.com
Wed May 21 14:09:17 EDT 2003


Andrew Walkingshaw wrote:
> 
> # set password to be blank initially
> password = ""
> # and create a variable to count the number of failed login attempts
> numfailures = 0
> 
> while numfailures < 3:
>     password = raw_input("Password: ")
>     if password == "unicorn":
>         # success, so get out of the loop
>         break
>     else:
>         # increment number of attempts by one
>         numfailures = numfailures + 1


Extremely minor nit: setting password to "" in the first
line above is useless in this case, as it will always be
set to the user input after the call to raw_input()...

-Peter




More information about the Python-list mailing list