0
Password Validation... my code isn't passing tests 5 and 12
userPassword = input() numCount = 0 specialCharCount = 0 for char in userPassword: if char == "0" or char == "1" or char == "2" or char == "3" or char == "4" or char == "5" or char == "6" or char == "7" or char == "8" or char == "9": numCount += 1 for char in userPassword: if char == "!" or char == "@" or char == "#" or char == "
quot; or char == "%" or char == "&" or char == "*": specialCharCount += 1 if numCount >= 2 and specialCharCount == 2 and len(userPassword) >= 7: print("Strong") else: print("Weak") Am I missing something?5 Answers
+ 1
Ghassan Al Khoury
specialCharCount >= 2
And I hope you know that += is not working in python.
+ 1
Oh I thought a minimum of 2 numbers only, didn't think the requirement wanted a minimum of 2 special characters as well. It worked. I really appreciate it. +=? Why not? It's working in my code tho
+ 1
Ghassan Al Khoury
Sorry my fault. I didn't know that python meanwhile accepted +=
+ 1
No worries :)) thanks for the help again
+ 1
from re import search as q
a = input()
if len(a) > 6 and q(r"\d.*\d", a):
if q(r"[!@#$%&*^].*[!@#$%&*^]", a):
print("Strong")
exit()
print("Weak")
# Hope this helps