+ 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")2 Réponses
+ 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:
+ 2
Ohh got it now. Thank you so much . 😊