+ 3
How can I make an if statement run the number of times the condition occurs?
I'm making a login form with python. And I put a condition for the password. If the pass is less than 8 it should print your password should be 8 or more 8 characters. But it only prints once. And if the user repeats the same mistake it does nothing. What can I do?
6 Answers
+ 8
Input your code in a loop, while loop specifically
+ 7
Put a while loop around your code:
while True:
psw= input("Enter your password or x to terminate: ")
if psw.lower() == 'x':
print('terminating ...')
break
elif len(psw) < 8:
continue
else:
print('your input was ok')
break
+ 4
That's where loops come into picture.
Learn about it heređ
https://www.geeksforgeeks.org/loops-in-JUMP_LINK__&&__python__&&__JUMP_LINK/
+ 3
Run your code under the while loop.
bool=true
while bool:
if len(psw) < 8:
#do your stuff
else:
bool=false
#do your stuff
+ 1
https://code.sololearn.com/cIVlwCBP9iC2/?ref=app
This is a part of the form I just had to type it here in solo learn playground.