I am new in Python and programming. I am trying to make a program that verifies that the entered password has a certain format. I was pretty sure my code was correct, but obviously...it's not. It won't exit the while loop when the password is in the correct format. Where is my mistake? Thank you all for your patience!
low = ['abcdefghijklmnopqrstuvwxyz']
up = ['ABCDEFGHIJKLMNOPQRSTUVWXYZ']
cr = ['@$%&']
digito = ['0123456789']
counter1 = 0
tries = True
while tries:
length = False
May = False
Minus = False
Num = False
Char = False
counter1 += 1
password = input('Password: ')
if len(password) > 7 and len(password) < 16:
length = True
for caracter in password:
if caracter in low:
Minus = True
if caracter in up:
May = True
if caracter in cr:
Char = True
if caracter in digito:
Num = True
if length and May and Minus and Num and Char:
print('Password ok.')
passw = password
tries = False
if counter1 == 5:
print('You had 5 attemps.')
break