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?

8th Mar 2021, 6:37 PM
Ghassan Al Khoury
Ghassan Al Khoury - avatar
5 Réponses
+ 1
Ghassan Al Khoury specialCharCount >= 2 And I hope you know that += is not working in python.
8th Mar 2021, 6:59 PM
Denise Roßberg
Denise Roßberg - avatar
+ 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
8th Mar 2021, 7:04 PM
Ghassan Al Khoury
Ghassan Al Khoury - avatar
+ 1
Ghassan Al Khoury Sorry my fault. I didn't know that python meanwhile accepted +=
8th Mar 2021, 7:08 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
No worries :)) thanks for the help again
8th Mar 2021, 7:09 PM
Ghassan Al Khoury
Ghassan Al Khoury - avatar
+ 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
9th Mar 2021, 9:26 AM
Calvin Thomas
Calvin Thomas - avatar