Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # this program checks if a password is valid or not
- def main():
- print("The password must be 8 characters long")
- print("The password must have at least one upper case and one lower case")
- print("The password must contain at least one digit")
- userPass = input("Please enter a password: ")
- confirmPass = isValidPassword(userPass)
- print(confirmPass)
- while confirmPass is True:
- userConfirm = input("Re-enter your password: ")
- if userPass == userConfirm:
- print("The passwords match")
- confirmPass = False
- else:
- print("Passwords do not match")
- print("")
- def isValidPassword(userPass):
- clearPass = False
- if len(userPass) >= 8:
- clearPass = True
- else:
- clearPass = "Must have 8 or more characters"
- if userPass.islower() is not True:
- clearPass = True
- else:
- clearPass = "Must have one lower character"
- if userPass.isupper() is not True:
- clearPass = True
- else:
- clearPass = "Must have one upper character"
- if userPass.isalnum() is True:
- clearPass = True
- return clearPass
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement