+ 3
1 test case failed out of 18. (I'm stuck)
Is there a problem in my code? i'm trying to solve this coad coach problem called password validation but i'm always getting this 1 test case failed. (test case no. 8 which is hidden so the output can not be track). I've tried everthing but i'm stuck! i am using python to solve this issue the problem is in the code coach with the name password validation (hard section). P. S. sorry for any grammer mistakes i'm not a native speaker. This is my first post so you can expect mistakes. Also i have already tried removing whitespaces using strip and replace method but it didn't work. https://code.sololearn.com/c5yY8OGDpQrp/?ref=app
4 Réponses
+ 6
Ishan Shah , The reason of the problem is the comparison of the 2 lists "required" and list "result". when inputting the password: 1234&gggg, the result is shown here.
the comparison of the lists is done lexicographically, means that the list "result" is greater than list "required", because the values will be compaired pairwise. only when both values are identical, the next pair will be evaluated. in our case 4 is greater than 2, so list "result" will match the if statement. you should do an other comparison between the 2 lists.
1234&gggg # input
Strong # your output
>>> required
[2, 2, 7]
>>> result
[4, 1, 9]
>>> result >= required
True
+ 5
Ishan Shah , i did a try for solving the issue with the comparison of the 2 lists:
- use the 2 lists and zip() them together and convert them to a list. so you will have a list of tuples with the pairs each having:
[(result, required), (result,...)...]
- now you can compare index 0 against index 1 of each tuple. you can use a for loop that enables you to compare the elements of the tuples, or you can use all(), that is shorter in code than the for loop.
do a try. if you get stuck somewhere, just come back that we can help you.
happy coding 👍
+ 2
Lothar Yep man thanks a lot i did that index wise and it worked.. spend a lot of time solving it but learned twice as much thanks again for clearing the concepts of list comparison i appreciate it ❤️
+ 1
You'r program printing output strong when special characters is 0. Test this case..
I think list comparing is giving wrong... Ex : Case [3, 0,7]