+ 2

When we give solution to a coding problem , why 1 out of 13 case fails ?

Why do the single test case not work with same piece of code rest are working? Here is password validator program link https://www.sololearn.com/coach/76?ref=app Which according to me is perfectly fine But it is not working for test case 8? Can anyone please let me know why?

18th Jun 2020, 3:28 PM
Prince Yadav
Prince Yadav - avatar
15 Respostas
+ 6
The link you provided leads to the code coach itself.
18th Jun 2020, 3:31 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 6
Prince Yadav, just store your attempt in a code in Playground and link it here, then we'll take a look at the problem. Or you copypaste it here, since they're generally short. Lynx, giving him *your* solution will not help him understand *his* mistake.
18th Jun 2020, 4:12 PM
HonFu
HonFu - avatar
+ 2
Ok sorry for it
18th Jun 2020, 3:35 PM
Prince Yadav
Prince Yadav - avatar
+ 2
Your result comes out as strong even if you have less than 2 of the symbols in it.
19th Jun 2020, 12:32 PM
HonFu
HonFu - avatar
+ 1
Doesn't isa(n) always return True ?
18th Jun 2020, 7:31 PM
Ê·á”–âżÊ·á”‡âż
Ê·á”–âżÊ·á”‡âż - avatar
+ 1
Lynx no it returns 1 when the character match with 7 special characters
19th Jun 2020, 3:50 AM
Prince Yadav
Prince Yadav - avatar
+ 1
'if x or y or z' doesn't mean what you think it means. It means: if x is truthy or y is truthy or z is truthy. Every string that's not empty ('') is truthy, so that function indeed always returns 1. You probably want to find out if n is one of the symbols. One pattern you can use: if n in (x, y, z): ...
19th Jun 2020, 6:58 AM
HonFu
HonFu - avatar
+ 1
Prince Yadav line 27. Just add "or x<2"
19th Jun 2020, 1:09 PM
Ê·á”–âżÊ·á”‡âż
Ê·á”–âżÊ·á”‡âż - avatar
0
#password validator a=input() def isd(n): if ord(n)<58 and ord(n)>47: return 1 return 0 def isa(n): if '!' or '&' or '*' or '#' or '
#x27; or '%' or '@': return 1 return 0 def lv(a): b=len(a) if b>=7: return 1 return 0 def pv(a): if not lv(a) : return 0 z=0 x=0 for i in a: if i==' ': return 0 if isd(i): z+=1 if isa(i): x+=1 if z<2: return 0 return 1 if pv(a): print ('Strong') else : print ('Weak')
18th Jun 2020, 5:01 PM
Prince Yadav
Prince Yadav - avatar
0
HonFu As you suggested, I made a change in my code Link: https://code.sololearn.com/cb8GAiZf7k6N/?ref=app Still it is failing in test case 8
19th Jun 2020, 12:23 PM
Prince Yadav
Prince Yadav - avatar
0
I think the error is not inside special character validator fxn It's somewhere else Please help me
19th Jun 2020, 12:24 PM
Prince Yadav
Prince Yadav - avatar
0
Prince Yadav you still have to check if there more than 2 special chars.
19th Jun 2020, 1:03 PM
Ê·á”–âżÊ·á”‡âż
Ê·á”–âżÊ·á”‡âż - avatar
0
Thanks to all Now it is working
19th Jun 2020, 1:43 PM
Prince Yadav
Prince Yadav - avatar
0
This is an approach import re def password_validation(password): numbers = re.findall(r'[0-9]', password) specialChars = re.findall(r'\W', password) if len(password) > 6 and len(numbers) > 1 and len(specialChars) > 1: return 'Strong' return 'Weak' print(password_validation(input()))
20th Jun 2020, 3:56 AM
Jonathan Alvarado
Jonathan Alvarado - avatar
20th Jun 2020, 9:51 AM
$±𝐎â‚č𝔭!𝐹𝓝
$±𝐎â‚č𝔭!𝐹𝓝 - avatar