Create a Password Validator using Python

What is a Password Validator?
The first question that arises in your mind is what is a password validator. A Password Validator is a program which verify and check your password according to the given criteria. The password has to fulfill the conditions to be valid otherwise invalid.

Algorithm behind this:

  1. Take an input.
  2. Check the password (input) for numbers.
  3. Check the password (input) for symbols.
  4. Use an If…Else Statement to check out the given conditions to verify.

Sounds Simple? Let's find that out

p = input()
n = "1234567890"
s = "!@#$%&*"
nc = 0
sc = 0
for i in p:
                 if i in nc:
                                 n += 1
                 elif i in s:
                                 sc += 1
 if len(p) >= 7 and n >= 2 and sc >= 2:
                 print ("Strong")
 else:
                 print ("Weak")

0 Comments