Advertisement
viligen

password_validation

Oct 10th, 2021
1,385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. def pass_validation(any_password):
  2.     counter_digit = 0
  3.     if 6 <= len(any_password) <= 10:
  4.         len_check = True
  5.     else:
  6.         len_check = False
  7.         print(f"Password must be between 6 and 10 characters")
  8.     if not any_password.isalnum():
  9.         print("Password must consist only of letters and digits")
  10.     for char in any_password:
  11.         if char.isdigit():
  12.             counter_digit += 1
  13.     if counter_digit >= 2:
  14.         digit_check = True
  15.     else:
  16.         digit_check = False
  17.         print(f"Password must have at least 2 digits")
  18.  
  19.     return len_check, any_password.isalnum(), digit_check
  20.  
  21.  
  22. password = input()
  23.  
  24. if all(pass_validation(password)):
  25.     print(f"Password is valid")
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement