Check the validity of password input by users

In this program, we will check the validity of password input by users.

Steps to solve the program
  1. Import re library.
  2. Take input through the user.
  3. Check the validity of the password by using re.search() and while loop.
  4. Test the given conditions.
  5. Print the output.
				
					import re
p = input("Input your password: ")
state = True

while True:  
    if (len(p)<5 or len(p)>15):
        break
    elif not re.search("[a-z]",p):
        break
    elif not re.search("[0-9]",p):
        break
    elif not re.search("[A-Z]",p):
        break
    elif not re.search("[$#@]",p):
        break
    elif re.search("\s",p):
        break
    else:
        print("Valid Password")
        state = False
        break

if state:
    print("Not a Valid Password")
				
			

Output :

				
					Input your password: Sqatools#1@
Valid Password
				
			

get the Fibonacci series between 0 to 10

check whether a string contains an integer or not

Leave a Comment