+ 1

Special Character

I have written the code for the below problem. It is running well but it is not able to satisfy certain cases. Please help me to figure out the bug. Thanx..... Given a string S, check whether it contains any special character or not. Print 'YES' if it does else 'NO'. Input Format: The first line contains the string S Output Format: Print 'YES' or 'NO' Example: Input: Hi$my*name Output: YES https://code.sololearn.com/cH1iklOAiAN6/?ref=app

10th Apr 2019, 9:34 PM
Nilutpol Kashyap
Nilutpol Kashyap - avatar
4 ответов
+ 3
s is a String and m is a number, so I think if(s == m) does not make sense. Why don't you make a list with special characters in it? And then for i in s -> if i in list -> print yes
10th Apr 2019, 10:32 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
I think I see what you are trying to do. You are basically counting the number of VALID characters there are, but you are not comparing that against the length of the string. Instead, like Denise said, you are comparing the number of characters, m, against the string itself, s. Instead you probably want: if m == n: Also, just change your alp and B to strings: alp = "abcdefghijklmnop......XYZ" B = "0123456789" Then it should work
11th Apr 2019, 12:19 AM
Zeke Williams
Zeke Williams - avatar
+ 1
Denise Roßberg thanx a lot. ot worked
11th Apr 2019, 7:05 AM
Nilutpol Kashyap
Nilutpol Kashyap - avatar
+ 1
Zeke Williams thanx a lot
11th Apr 2019, 7:05 AM
Nilutpol Kashyap
Nilutpol Kashyap - avatar