0

I'm making a program and it needs a while loop to repeat a process. I don't really understand while loops, and the demonstrations online don't really help with my situation.

while true:
    if password == 1526:
        typewriter ("ACCESS GRANTED")

else:
    typewriter ("ACCESS DENIED")
    typewriter ("You must enter the password correctly to proceed. ")

    typewriter ("Please input password: ")
    password = int(input (""))
4
  • you want loop to run always? Commented May 20, 2017 at 12:56
  • yes, until the user inputs the code correctly Commented May 20, 2017 at 13:03
  • Check the answer i posted below Commented May 20, 2017 at 13:05
  • thanks for your help Commented May 20, 2017 at 13:19

1 Answer 1

2

What I understand is, you want to prompt for entering password until input/password is 1256.

while True:
    typewriter("Please input password: ")
    password = int(input ("")) 

    if password == 1526:
        typewriter ("ACCESS GRANTED")
        break
    else:
        typewriter ("ACCESS DENIED")
        typewriter ("You must enter the password correctly to proceed. ")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.