Password validation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Password validation

password = input() count = 0 count1 = 0 chars = ['!', '@', '#', '

#x27;, '%', '&', '*'] for ch in password: if ch.isdigit: count+=1 if ch in chars: count1+=1 chars.remove(ch) if ((count >= 2) and (count1>=2)) and (len(password) >= 7): print("Strong") else: print("Weak") So I can not pass test 10 and 11, but if I remove line chars.remove(ch) I can’t pass only test number 7. Can someone help? :)

5th Sep 2020, 8:32 AM
Artem
3 Answers
+ 1
Count is not counting the digits, it's counting the characters in the password Put () If ch.isdigit():
5th Sep 2020, 10:09 AM
Roy
Roy - avatar
+ 2
In the paasword validator there are a case of LeTme!n so there is only one occurence of chars.So you have to reset your condition of chars count1 .
5th Sep 2020, 9:10 AM
HBhZ_C
HBhZ_C - avatar
0
Indentation is not the problem, bc i copied it and indentation felt apart. But I still dont understand why without remove specific test is’nt working. But with removing it works perfectly - makes no sense
5th Sep 2020, 9:37 AM
Artem