need help with this program!!!!1

[b][red]This message was edited by ZeroOverRid at 2003-10-12 13:53:35[/red][/b][hr]
ok here the program

#waits until a password has been entered.
password = "footbar"
while password != "unicorn":
passwoed = raw_input("passoword:")
print "welcome in"

now here what i have to do

modigy the passwoed guessing program to keep track of how many times theuser has entered the password wrong. If it is more than 3 times, print "That must have been complicated"
i can't firgure out how to do this the only way i can think of a way is using while somehow

thanks
ZeroOverRid



Comments

  • : [b][red]This message was edited by ZeroOverRid at 2003-10-12 13:53:35[/red][/b][hr]
    : ok here the program
    :
    : #waits until a password has been entered.
    : password = "footbar"
    : while password != "unicorn":
    : passwoed = raw_input("passoword:")
    : print "welcome in"
    :
    : now here what i have to do
    :
    : modigy the passwoed guessing program to keep track of how many times theuser has entered the password wrong. If it is more than 3 times, print "That must have been complicated"
    : i can't firgure out how to do this the only way i can think of a way is using while somehow
    :
    : thanks
    : ZeroOverRid
    :
    :
    :
    :
    Here's one way:

    [code]
    retries, password, answer, correct = 3, None, 'unicorn', 0

    while retries:
    if raw_input("Password:") == answer:
    print "You got it right"
    correct = 1
    break
    else:
    retries -= 1

    if not correct:
    print "Wrong three times."

    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion