+ 2
Coach Password Validation Test Case #13 Error
I can't figure out what's wrong with this code for the password validation challenge It only failed 1 of the 13 test cases, and the one it failed is hidden #13. Help? import re password=input() if password!="": reg = "^(?=.*\d{2,})(?=.*[@$!%*#&]{2,})[A-Za-z\d@$!#%*&]{7,}
quot; pat = re.compile(reg) mat = re.search(pat, password) if mat: print("Strong") else: print("Weak")2 Antworten
+ 7
SalahEddine ntifi , I think the pattern is ok. But when I input this:
> 123qwe#$%< (if the first character is a space or any other invalid character, the answer will be):
None
Weak
There could also be an other reason for a problem, when NO input is given, and only return is pressed.
In this case there will not be anything in output.
0
I try this but no result
This is the new code
import re
password=input()
if password!="":
reg = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d{2})(?=.*[@$!%*#&]{2})[A-Za-z\d@$!#%*&]{7,}quot;
if ' ' in password:
space=True
else:
pat = re.compile(reg)
mat = re.search(pat, password)
if mat:
print("Strong")
else:
print("Weak")
else:
print('Weak')