+ 2

What's wrong with my code coach 'password validation' python solution?

Here is the code, it works for all but 2 test cases: import re password = input() if re.search(r"[0-9]{2,}[!@#%&\$\*]{2}[A-Za-z]*", password) and len(password) >= 7: print ("Strong") else: print ("Weak") https://code.sololearn.com/csy74RDDJ4ap/?ref=app

21st Apr 2022, 9:24 AM
Stephen Laz-Eke
Stephen Laz-Eke - avatar
4 Respostas
+ 2
If the digit or special are after the letters, it states weak instead of strong.
21st Apr 2022, 9:40 AM
John Wells
John Wells - avatar
+ 1
John Wells Thanks alot, please how do you think I can fix this?
21st Apr 2022, 9:46 AM
Stephen Laz-Eke
Stephen Laz-Eke - avatar
0
Stephen Laz-Eke I looped through the password counting the digits and specials. Afterwards, tested length, digits, and specials for their minimum.
21st Apr 2022, 10:14 AM
John Wells
John Wells - avatar
0
John Wells Okay. Thanks alot. I appreciate. Do you know anyway to make regex not to be rigid in positioning?
21st Apr 2022, 11:41 AM
Stephen Laz-Eke
Stephen Laz-Eke - avatar