简体   繁体   中英

How would I use a while true loop in this?

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 (""))

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. ")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM