0

Here is my code:

print("Welcome to Makiah's Password Checker")
print("""
Your password must contain the following elements:

-Your password must be at least 8 characters long.
-Your password must have at least one uppercase and one lowercase letter.
-Your password must have at least one digit.
""")

password1 = input("Enter your new password: ")

password2  = input("Please re-enter your password: ")

while password1 != password2:
    print("Those passwords do not match.")
    password1 = input("Enter your new password: ")
    password2  = input("Please re-enter your password: ")
print("Those passwords match.")

def isValidPassword(password):
    test = True
    if len(password) <8:
        print("Length should be at least 8 characters")
        test = False
    if not any(char.isdigit() for char in password):
        print("password should have at least one number")
        Test = False
    if not any(char.isupper() for char in password):
        print("Password should contain one uppercase letter")
        test = False
    if not any(char.islower() for char in password):
        print("Password should contain one lowercase letter")
        test = False
    if test:
        return test
while isValidPassword(password1) == False:
    print("Your password is not valid")
    #Need new code here

I need something that when detected as invalid restarts the user back at the beginning of the checker so they can check again I have tried a few things but am new to python and am not sure what to do.

  • There are no classes in your code, what is the `class` tag for? Don't use that if the code is for a school class. – Barmar Mar 01 '22 at 00:06

0 Answers0