dimanche 31 mai 2020

Python- Why does it say password denied even when I enter a password that should work?


userpass= input('Enter a password with at least one uppercase letter, one lowercase letter, and one number: ')
uppercounter=0
lowercounter=0
numbercounter=0
for i in range(len(userpass)):


    if userpass[i].isupper():
        uppercounter=uppercounter+1
        print(uppercounter)
        if uppercounter > 0:
            print("working")
    else:
        print('Password Denied')
        raise SystemExit(0)

    if userpass[i].islower():
        lowercounter=lowercounter+1
        print(lowercounter)
        if lowercounter > 0:
            print('working')
    else:
        print('Password Denied')
        raise SystemExit(0)

    if userpass[i].isnumeric():
        numbercounter=numbercounter+1
        print(numbercounter)
        if numbercounter > 0:
            print("working")
            print("Password Accepted")
    else:
        print('Password Denied')
        raise SystemExit(0)

I’m trying to make a program for a password that must contain one uppercase letter, one lowercase letter, and one number. But the if statements don’t seem to be working properly and whenever I enter a password like “Py11”, it says password denied.

Aucun commentaire:

Enregistrer un commentaire