+ 1

(Py) Password Validation exercise

Failing only 1 test case and not sure why. Code: import re pword = input() pattern = r'[!@#$%&*]{2,}' if len(pword) < 7: print("Weak") elif re.search(r'\d+\d+',pword): if re.search(pattern,pword): print("Strong") else: print("Weak") else: print("Weak")

20th Mar 2020, 7:55 PM
Kevin Holt
Kevin Holt - avatar
2 Antworten
+ 2
Better to use this. No need to use re module 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 if numbChar >=2 and numbInt >= 2 and len(userStr) >= 7: print("Strong") else: print("Weak")
22nd Mar 2020, 10:24 AM
Ramin.RX7
Ramin.RX7 - avatar
- 3
no
24th Mar 2020, 3:31 AM
ML1022020 JOSHUA ETHAN CHEW WEI XUAN
ML1022020 JOSHUA ETHAN CHEW WEI XUAN - avatar