I am trying to solve Password Validation but it's not working. What is the wrong | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

I am trying to solve Password Validation but it's not working. What is the wrong

https://code.sololearn.com/c6gTOOZdPRwo/?ref=app

1st Sep 2021, 5:20 AM
SUJIT
SUJIT - avatar
18 ответов
+ 2
SUJIT No problem,here you go https://code.sololearn.com/c3pa6hB6L1AQ/?ref=app Let me know if you have any questions for the code
2nd Sep 2021, 1:34 AM
raynard
raynard - avatar
+ 3
You forgot to add an else statement for the last if statement that checks the length of the password,the strong and weak only gets printed out if the length is >= 7,so an additional else statement is needed for this
1st Sep 2021, 5:47 AM
raynard
raynard - avatar
+ 3
Delicate Cat I didn't get you. Can you please explain this?
1st Sep 2021, 6:09 AM
SUJIT
SUJIT - avatar
+ 2
Okay
2nd Sep 2021, 2:08 AM
SUJIT
SUJIT - avatar
+ 1
SUJIT can you tell me what is not working? Is it not printing anything? and a sample input would be useful
1st Sep 2021, 6:16 AM
raynard
raynard - avatar
+ 1
SUJIT I finally figured it out,i tried random test cases and one test case caught my eye,if you repeat the same special char and the same number in the password,the check only registers 1 count of the special char and 1 count of the number,therefore it returns "weak" What you need to do is convert the password into list, check each number and special in the password list,if found then get the real count of the special character and number using the count function of list,and then use that as the benchmark to check if its >= 2 Let me know if u need the code
1st Sep 2021, 9:01 AM
raynard
raynard - avatar
+ 1
SUJIT It basically assigns value to the list on each index ,making each value 1 string and not just the whole value ,you can do it either way with [0:] , [:0] or [0:0] or [0:-1] all works something like a list comprehension also works but thats simpler to write
2nd Sep 2021, 2:07 AM
raynard
raynard - avatar
0
raynard Your Answer is correct but still didn't working.
1st Sep 2021, 6:10 AM
SUJIT
SUJIT - avatar
0
raynard I am trying solve this Password Validation problem in Sololearn. All test cases are passed except two.
1st Sep 2021, 6:22 AM
SUJIT
SUJIT - avatar
0
SUJIT def numberCheker(s): m = 0 for i in s: if i.isdigit(): m += 1 if m >= 2: return True else: return False A number checker function like this should work better since it only checks for digit,but to my surprise it still fails on the two test cases,i might need to come back later
1st Sep 2021, 6:39 AM
raynard
raynard - avatar
0
raynard Thanks. Let me try first ,If I fail I will take your help.
1st Sep 2021, 11:33 AM
SUJIT
SUJIT - avatar
0
SUJIT no problem💪
1st Sep 2021, 2:10 PM
raynard
raynard - avatar
0
raynard I am unable to solve the problem though I understood your logic. Can you please give me the code?
2nd Sep 2021, 1:18 AM
SUJIT
SUJIT - avatar
0
Thank You raynard
2nd Sep 2021, 1:35 AM
SUJIT
SUJIT - avatar
0
"passwo[:0]=passw" raynard why you write this line?
2nd Sep 2021, 1:52 AM
SUJIT
SUJIT - avatar
0
How come on my code page I added the circle codes but they didn't work out
2nd Sep 2021, 9:45 PM
Julius Mugumya
Julius Mugumya - avatar
0
А В С
3rd Sep 2021, 4:17 AM
Александр Тырнов
0
Вы пидоры омерикански
3rd Sep 2021, 4:32 AM
Николай Татарчуков
Николай Татарчуков - avatar