Advertisement
BdW44222

06. Password Validator

Jun 11th, 2021
1,024
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  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 not password.isalnum():
  7.         print("Password must consist only of letters and digits")
  8.     if len(password) >= 6 or len(password) <= 10 and len([x for x in password if x.isdigit()]) == 2 and password.isalnum():
  9.         print("Password is valid")
  10.  
  11.  
  12. user_password = input()
  13. password_validator(user_password)
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement