Wap to check validity of password in python

import re

flag=0
passwd=input(“Enter your password”)
if not re.search(‘[a-z]’,passwd):
flag = 1
if not re.search(‘[0-9]’,passwd):
flag = 1
if not re.search(‘[A-Z]’,passwd):
flag=1
if not re.search(‘[$@#!]’,passwd):
flag = 1
if len(passwd)<6:
flag = 1

if (flag == 0):
print(“password is valid:”)
else:
print(“password is invalid:”)

2 Likes

very nice, keep it up… try to make your code shorter by merging
conditions with or operator

1 Like

yes mam definitely :slightly_smiling_face:

1 Like