0
Name and password loops repeat
6 Respostas
+ 3
While True makes the while loop infinite.
So it won't break until you break it with the "break" keyword inside the loop with a condition.
+ 2
I think you want something like this:
https://code.sololearn.com/cA23a10A5a3a
+ 2
I have used i +=1 for counting 3 times
i+=1 means it will increment 1 in the value of i .
So if,
the value of i is 0
after,
i+=1
the value of i will become 1.
You will learn soon about increment and decrement operators.
+ 1
Interesting. What exactly is the "+=" doing? Have not gotten that far. I just started tonight with reading "Automating the Boring Stuff"
+ 1
J Does this work? :-
import time
i = j = 0
while j < 3:
inp = input("ENTER: ")
if inp == "12345": break
print("Incorrect Password!")
i += 1
if i == 3:
i = 0
j += 1
print("Please wait for 3 minutes before trying again...")
time.sleep(180)
else:
print("Invalid password! This window will close in five seconds...")
time.sleep(5)
exit(-1)
+ 1
One more thing.
I'm a little confused about the
"While True"
For example
While true
Print ('enter username'l
Name = input()
If name == 'j'
Break
Print ('thank you')
I get how the if works.
But the while true part is confusing
While what is true? Or am I thinking about this incorrectly?