+ 6

What is missing in my code?

I am solving Password Validation Challange and My code fails at Test case 1, 5 , and 9. But I don't know why !! Help me out. https://code.sololearn.com/c8miE87tvzPe/?ref=app

13th Jan 2020, 11:01 AM
Ashutosh R. Yadav
Ashutosh R. Yadav - avatar
29 odpowiedzi
+ 6
use v = set(x.strip()) instead of split()
13th Jan 2020, 11:32 AM
Bahhaāµ£
Bahhaāµ£ - avatar
+ 6
you are not checking for special characters like "#&@" and capital letters.
13th Jan 2020, 11:06 AM
Bahhaāµ£
Bahhaāµ£ - avatar
+ 6
ä¹”AshutoshĀ°^Ā°Kumarä¹” that is because the methog you counted the rest of the characters is wrong, same problem again. If you change the part where you count the special characters, it will work fine. Why is the idea behing using set() ? It seems only disturbing to me, and unecessary.
13th Jan 2020, 11:27 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 5
From what I see, your code does not count the number of special characters. It only counts the number of characters that are different that numbers and alphabets, and not those specific characters.
13th Jan 2020, 11:04 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 5
ä¹”AshutoshĀ°^Ā°Kumarä¹” it is probably because of how you counted the letters. You removed the alphabets and numbers to get the last missing number of characters. The space counts as a character, and therefore might be the reason a condition is True.
13th Jan 2020, 11:32 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 5
bahhašŸ§ I was about to write that šŸ‘Œ
13th Jan 2020, 11:33 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
ä¹”AshutoshĀ°^Ā°Kumarä¹” as said before, you are counting all the characters, and not just those special characters. Even Ā„ would be counted in m, but it does not exist in special characters, so your code is wrong.
13th Jan 2020, 11:17 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
srry I dont do python i do c++ though
14th Jan 2020, 2:45 PM
Abedalrahman Abughazaleh
Abedalrahman Abughazaleh - avatar
+ 3
I have to learn python but not getting it in my mind
14th Jan 2020, 4:20 PM
Nitin Kumar Rajpoot
Nitin Kumar Rajpoot - avatar
+ 3
Mikhail actually no, it's "What is wrong with my code?" ä¹”AshutoshĀ°^Ā°Kumarä¹” I already answered and told you what I think was wrong, why don't you give it a try ?
15th Jan 2020, 9:58 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
ä¹”AshutoshĀ°^Ā°Kumarä¹” I answered that post as well.
15th Jan 2020, 10:05 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
13th Jan 2020, 11:35 AM
Bahhaāµ£
Bahhaāµ£ - avatar
+ 2
Can you explain that why strip() works but split() don't.? How strip () function works? Explain me please.
13th Jan 2020, 11:41 AM
Ashutosh R. Yadav
Ashutosh R. Yadav - avatar
+ 2
strip() removes whitespace characters like space, tab. when no parameter is used. I just thought of it when you mentioned, it worked without space anyway the code would work without strip() too. set(x)
13th Jan 2020, 11:49 AM
Bahhaāµ£
Bahhaāµ£ - avatar
+ 2
Thanks bro
13th Jan 2020, 11:57 AM
Ashutosh R. Yadav
Ashutosh R. Yadav - avatar
+ 2
Ajay Dayma I know nothing about cpp xD
14th Jan 2020, 4:07 PM
Ashutosh R. Yadav
Ashutosh R. Yadav - avatar
+ 2
l = set(alpha) | set(digit) i used In place of (| = & ) Then checked it shows strong password given in your code
14th Jan 2020, 4:29 PM
Sonu Kumbhkar
Sonu Kumbhkar - avatar
+ 2
ŠœŠ¾Š¶ŠµŃ‚ ŠæрŠ¾Š²ŠµŃ€ŃŃŽŃ‚ тŠµŃ€ŠæŠµŠ½ŠøŠµ?
14th Jan 2020, 11:54 PM
Š Š°ŠµŠ½ Š‘Š¾ŃŠŗ
Š Š°ŠµŠ½ Š‘Š¾ŃŠŗ - avatar
+ 2
Yup may be
15th Jan 2020, 10:29 AM
Ashutosh R. Yadav
Ashutosh R. Yadav - avatar
+ 1
Kindly see the code. I am storing the alphabets in a list. Then digits in a different list. Then I am subtracting these both lists from my input and storing it in variable m. Now I counting alphabets, digits, and m ( special characters). Then what is wrong here.. check it again guys Aymane Boukrouh [INACTIVE] bahhašŸ§
13th Jan 2020, 11:16 AM
Ashutosh R. Yadav
Ashutosh R. Yadav - avatar