Untitled

mail@pastecode.io avatar
unknown
python
a year ago
918 B
2
Indexable
Never
is_password_invalid=True
while is_password_invalid:
    password=input("Enter your password")
    length_condition=False
    upper_condition=False
    lower_condition=False
    special_condition=False
    numeric_condition=False
    if len(password)>=8:
        length_condition = True
    for i in password:
        if i.islower():
            lower_condition = True
        if i.isupper():
            upper_condition = True
        if i.isnumeric():
            numeric_condition = True
        if not i.isalnum():
            special_condition = True
    if length_condition and upper_condition and lower_condition and special_condition and numeric_condition:
        print("Password is valid")
        is_password_invalid = False
    else:
        print("Password is invalid, password should have at least 8 characters, at least one uppercase letter, one lowercase letter, one number, and one special character.")