Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. # this program checks if a password is valid or not
  2.  
  3. def main():
  4.     print("The password must be 8 characters long")
  5.     print("The password must have at least one upper case and one lower case")
  6.     print("The password must contain at least one digit")
  7.     userPass = input("Please enter a password: ")
  8.     confirmPass = isValidPassword(userPass)
  9.     print(confirmPass)
  10.     while confirmPass is True:
  11.         userConfirm = input("Re-enter your password: ")
  12.         if userPass == userConfirm:
  13.             print("The passwords match")
  14.             confirmPass = False
  15.         else:
  16.             print("Passwords do not match")
  17.             print("")
  18.  
  19. def isValidPassword(userPass):
  20.     clearPass = False
  21.     if len(userPass) >= 8:
  22.         clearPass = True
  23.     else:
  24.         clearPass = "Must have 8 or more characters"
  25.     if userPass.islower() is not True:
  26.         clearPass = True
  27.     else:
  28.         clearPass = "Must have one lower character"
  29.     if userPass.isupper() is not True:
  30.         clearPass = True
  31.     else:
  32.         clearPass = "Must have one upper character"
  33.     if userPass.isalnum() is True:
  34.         clearPass = True
  35.     return clearPass
  36. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement