I'm just a few months into learning python and I'm trying to write a program which will help to test characteristics of a password. I'm so close to getting what I need but one line seems like it keeps getting skipped and I can't figure out why... Here's the code:
def main():
print("Create a password. Password must follow these rules:")
print(" - password must be at least 8 characters long")
print(" - password must have one uppercase AND lowercase letter")
print(" - password must have at least one digit")
isValidPassword()
def isValidPassword():
password = []
password2 = []
print()
print("Enter password:", end="")
pass1 = input("")
print("Re-enter password:", end="")
pass2 = input("")
password.append(pass1)
password2.append(pass2)
if password == password2 and len(password) >= 8 and password.isupper() == False and password.islower() == False and password.isalpha() == False and password.isdigit() == False:
print("Password will work.")
else:
print("Password will not work. Try again.")
isValidPassword()
main()
When I run the code, the print statement ("Password will work.") underneath my if statement will not print, even though I enter a password which meets all of the requirements. I have run the if statement in another file, outside of the def isValidPassword() function and it seems to work just fine.
Can anybody lend me any insight as to why this won't work..?
Aucun commentaire:
Enregistrer un commentaire