Advertisement
pacho_the_python

Untitled

Feb 9th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. def pass_validator(password):
  2.     pass_len = False
  3.     pass_letter_digit = False
  4.     pass_digit_sum = False
  5.  
  6.     if 6 <= len(password) <= 10:
  7.         pass_len = True
  8.     else:
  9.         print("Password must be between 6 and 10 characters")
  10.  
  11.     for i in password:
  12.         if i not in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789":
  13.             pass_letter_digit = False
  14.             print("Password must consist only of letters and digits")
  15.             break
  16.         else:
  17.             pass_letter_digit = True
  18.  
  19.     counter = 0
  20.     for j in password:
  21.         if j in "1234567890":
  22.             counter += 1
  23.     if counter < 2:
  24.         print("Password must have at least 2 digits")
  25.     else:
  26.         pass_digit_sum = True
  27.  
  28.     if pass_digit_sum and pass_len and pass_letter_digit:
  29.         print("Password is valid")
  30.  
  31.  
  32. word = input()
  33.  
  34. pass_validator(word)
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement