+ 3

How can I solve this Code coach problem?

I've written a program in python to solve the code coach problem called "Password Validation". But 1 out of 13 test cases is showing me incorrect. I can't seem to solve this issue. Can anyone check my code and suggest any solution? x = input() count_num = 0 count_char = 0 num = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] spcl_char = ["!", "@", "#", "

quot;, "%", "&", "*"] if len(x) < 7: print("Weak") else: for i in x: if i in num: count_num += 1 elif i in spcl_char: count_char += 1 else: continue if count_num > 1 and count_char > 1: print("Strong") else: print("Weak")

22nd May 2020, 3:43 PM
Nayomi Hasan
Nayomi Hasan - avatar
2 Answers
+ 2
Second if doesn't check the length again. Reduce it: <no if-else> for i in x: if i in num: count_num += 1 elif i in spcl_char: count_char += 1 else: continue if len(x) > 7 and count_num > 1 and count_char > 1:
22nd May 2020, 3:51 PM
Sandra Meyer
Sandra Meyer - avatar
+ 2
Ohh got it now. Thank you so much . 😊
22nd May 2020, 3:53 PM
Nayomi Hasan
Nayomi Hasan - avatar