Advertisement
Spocoman

09. Password Validator

Jan 28th, 2022
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. def solve():
  2.     password = input()
  3.     digits = 0
  4.     output = ''
  5.     if len(password) < 6 or len(password) > 10:
  6.         output += "Password must be between 6 and 10 characters\n"
  7.     for i in password:
  8.         if 64 < ord(i) < 91 or 96 < ord(i) < 123 or 47 < ord(i) < 58:
  9.             if 47 < ord(i) < 58:
  10.                 digits += 1
  11.         else:
  12.             if not "Password must consist only of letters and digits" in output:
  13.                 output += "Password must consist only of letters and digits\n"
  14.                 break
  15.     if digits < 2:
  16.         output += "Password must have at least 2 digits"
  17.     if output == '':
  18.         output = "Password is valid"
  19.     return output
  20.  
  21.  
  22. print(solve())
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement