can some one help me to find any fault in this code for PRPALN

This code is running fine for the input i have tested

t = raw_input()

t = int(t)

for i in range(t):

s = raw_input()
l = len(s)
y = 0
j = l-1
cnt = 0
for k in range(l/2):
	if(s[k] == s[j]):
		y = 1
	else:
		if cnt > 0:
			y = 0
			break;
		if(s[j-1] == s[k] ):
			j = j - 1
			cnt = cnt + 1
		elif(s[j] == s[k+1]):
			i = i+1
			cnt = cnt + 1
	j = j-1
if( y == 1):
	print 'YES'
elif( y == 0 ):
	print 'NO'

Check for this input

ahadadah

Palindrome can be formed on deleting first character β€˜a’, so answer is β€œYES”. Your code outputs β€œNO”

1 Like

So many missed your test case, I’m glad you are replying :wink:

Thanks buddy.