Please Help Me

My Code is given wrong answer
can anyone help me
problem Link Contest Page | CodeChef
My Code:
for _ in range(int(input())):
arr=list(map(str,input().split()))
s="".join(arr)
bad_char=["!","@","#","$","%","^","&","*","/","{","}","[","]","(",")","<",">","|",".",",","~","`","?","+","-","_"]
s="".join(i for i in s if(not i in bad_char))
s=s.lower()
if(s==s[::-1]):
print(“YES”)
else:
print(“NO”)

1 Like

I think you are getting WA because you are forgetting "\" as a special character…

Just add that and it should work…

Also, more importantly you have forgotten the number condition!
You can’t have digits in the string!

Here is the fixed code I submitted based on your idea: AC solution

Why do all that hard work, just include the alphabets and ignore everything else AC_CODE

You forgot the number conditions in palandrom that’s why your code throws an error

If you want you can check the below code for more help…

for _ in range(int(input())):
a = input()
arr = [‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘0’]
s = “”
for i in a:
if i in arr:
print(“NO”)
break
if 65<=ord(i)<=90 or 97<=ord(i)<=122:
s+=i.lower()
else:
if s[::-1]==s:
print(“YES”)
else:
print(“NO”)