How to research two special characters in password using python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 10

How to research two special characters in password using python?

For one time I can search a special character like this: elif not re.search("[@$!#%&*]", password): flag = -1 break

22nd Mar 2020, 2:34 AM
Wali Khan Eisakhil
Wali Khan Eisakhil - avatar
2 Answers
+ 2
Sym =['!', '@', '#', '
#x27;, '%', '&', '*'] userStr = input() for char in userStr: if char in Sym: numbSym+=1 Full code: chars =['!', '@', '#', '
#x27;, '%', '&', '*'] userStr = input() numbChar=0 numbLett=0 numbInt=0 #get the requirements for char in userStr: if char in chars: numbChar+=1 elif char.isdigit(): numbInt+=1 elif char.isalpha(): numbLett+=1 #check the requirements if numbChar >=2 and numbInt >= 2 and len(userStr) >= 7: print("Strong") else: print("Weak")
22nd Mar 2020, 10:28 AM
Ramin.RX7
Ramin.RX7 - avatar
+ 1
Wali Khan Eisakhil spe = "@$!#&*" specount = 0 for i in spe: if i in pw: specount += 1
22nd Mar 2020, 5:00 AM
maf
maf - avatar