0

password validator puzzle

https://www.sololearn.com/coach/76?ref=app Howwww??, it is working fine for all test cases Except test case 10 and 11 which are hidden so i cant even find whats wrong, can anyone help me , its a password validator paw = input() spe = ('!', '@', '#', '

#x27;, '%', '&', '*') a=b=0 for i in range(len(spe)): if spe[i] in paw: a += 1 for i in range(0,10): if str(i) in paw: b += 1 if (a < 2 or len(paw) < 8) or (b < 2): print('Weak') else: print('Strong')

29th Jun 2021, 6:25 PM
Kairav Bhatia
Kairav Bhatia - avatar
5 ответов
+ 2
should output "Strong" but your code output "Weak": abcd##42 abcd@%55
29th Jun 2021, 7:04 PM
visph
visph - avatar
+ 6
Kairav Bhatia , there seems to be an issue when inputting special characters that are not in tuple "spe". if i use this input it shows "Strong", even if it contains: "§/()=". hello123§$%&/()=? Strong this issue results from the way your for loop is working. try to find a way to avoid "not allowed" characters. happy coding and good success!
29th Jun 2021, 7:29 PM
Lothar
Lothar - avatar
+ 2
I figured it out rhe problem was repeating special symbols like @@ or ## and its good now thanks to both of you
29th Jun 2021, 7:49 PM
Kairav Bhatia
Kairav Bhatia - avatar
+ 2
Lothar there are no "not allowed character to handle" ;)
29th Jun 2021, 7:53 PM
visph
visph - avatar
0
Kairav Bhatia Here's a shorter way of doing this: a, b, c = input(), 0, 0 for x in a: if x.isdigit(): b += 1 elif x in "!@#$%&*": c += 1 print(("Weak", "Strong")[len(a) > 6 and b > 1 and c > 1]) # Hope this helps
1st Jul 2021, 12:28 PM
Calvin Thomas
Calvin Thomas - avatar