Password Input Coding Python

Asked 2 years ago, Updated 2 years ago, 19 views

If you receive a password and match the password you set, you'll be like, "Log in". 다시 Otherwise, I'll try again You must enter it. If the number of password errors is greater than 5 times, re-enter it in 60 seconds I'm going to create a code that does that. The password is 1234.

pwd = int (input ("password input"))
count = 0
while pwd !=1234:
    count +=1
    if count ==5 :
     print ("Re-enter after 60 seconds")
     for i in range(1,60+1):
         print (60-i 'wait seconds')
    count = 0
    pwd = int (input ("password input")
print ('Login')

I coded with first, but the lock doesn't work after 5 failures. I would appreciate it if you could let me know the solution.

python

2022-09-20 21:50

1 Answers

I'm not sure because the indentation of the code you wrote is a little ambiguous, but I think it's because the code that resets the count to 0 is outside the if statement.

if count ==5 :
    print ("Re-enter after 60 seconds")
    for i in range(1,60+1):
         print (60-i 'wait seconds')
    count = 0

You can write it like thisYo

And it's a little bit different, but if you execute the code that waits 60 seconds, it'll be over in a second.

There's actually a time-measuring module, so if you're interested, you might want to look it up.


2022-09-20 21:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.