+ 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
4 Answers
+ 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
+ 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
+ 1
Denise RoĂberg thanx a lot. ot worked
+ 1
Zeke Williams thanx a lot