BdW44222

06. Password Validator

Jun 10th, 2021
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def password_validator(password):
  2. if len(password) < 6 or len(password) >= 10:
  3. print("Password must be between 6 and 10 characters")
  4. if len([x for x in password if x.isdigit()]) < 2:
  5. print("Password must have at least 2 digits")
  6. if len([x for x in password if x.isalnum()]):
  7. print("Password must consist only of letters and digits")
  8. else:
  9. print("Password is valid")
  10.  
  11.  
  12. user_password = input()
  13. password_validator(user_password)
RAW Paste Data