vendredi 7 février 2020

How to check the validity of a password (input from users) without using import re?

I'm trying to check the validity of a password without using import re, but it always gives me not valid. Where is my error, please?

password = input('Enter your password: ')

while True:
    if password not in [i for i in range(0,9)]:
        print('not valid')
        break
    elif (len(password)<6 or len(password)> 9):
        print('not valid')
        break
    elif password not in [chr(c) for c in range(97, 123)]:
        print('not valid')
        break
    elif password not in [chr(c) for c in range(65, 91)]:
        print('not valid')
        break
    elif password not in ('$','#','@'):
        print('Not valid')
        break
    else:
        print('Valid')
        break

Aucun commentaire:

Enregistrer un commentaire