Advertisement
GeorgiLukanov87

password_validator_function100/100

Jun 10th, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. def password_validator(password_data):
  2.     is_valid = True
  3.     counter_digit = 0
  4.      
  5.     if not len(password_data) >= 6 and len(password_data) <= 10:
  6.         print('Password must be between 6 and 10 characters')
  7.         is_valid = False
  8.    
  9.     if not password_data.isalnum():
  10.         print('Password must consist only of letters and digits')
  11.         is_valid = False
  12.        
  13.     for digit in password_data:
  14.         if digit.isdigit():
  15.             counter_digit += 1
  16.     if not counter_digit >= 2:
  17.         print(f"Password must have at least 2 digits")
  18.         is_valid = False
  19.        
  20.     if is_valid:
  21.         print('Password is valid')
  22.  
  23.  
  24. current_password = input()
  25. password_validator(current_password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement