Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
707 B
3
Indexable
Never
def check_password(user_password ):

    suffix = ['%', '$', '#', '@', '!']
    user_password = str(user_password)
    x = len(user_password)

    if (x == 5) & (user_password[x - 1] in suffix):
        for i in range(x - 1 ):
            if int(user_password[i]) > 9 | int(user_password[i]) < 0:
                return "Wrong password"
        return "Correct password"
    else:
        return "Wrong password"



def enter_password():

    ask = "please enter password"
    print(ask)
    answer = str(input())
    while (check_password(answer) == "Wrong password") :
        print(ask+ ". Try again \n")
        answer = str(input())

    print("password saved ! Exiting... \n")


enter_password()