The Next Palindrome problem is giving wrong answer according to me it is correct

t = int(input())
for i in range(t):
num = str(input())
intnum = []
for z in range(len(num)):
intnum.append(int(num[z]))
# print(intnum)
leng = len(num)
if leng == 1:
print(“11”)
continue
b = []

lock = 0
for x in intnum:
    if x != 9:
        lock = 1
if lock ==0:
    print(int(num)+2)
    continue
till = 0

if leng%2 == 1:
    count = 0
    for j in range(int(leng/2), -1, -1):
        # print("j", j)
        if intnum[j] != 9:
            intnum[j] = intnum[j] + 1
            intnum[-j-1] = intnum[j]
            till = j
            break
        else:
            intnum[j] = 0
            intnum[-j-1] = 0

else:
    count = 0
    for j in range(int(leng/2)-1, -1, -1):
        # print("j", j)
        if intnum[j] != 9:
            intnum[j] = intnum[j] + 1
            intnum[-j-1] = intnum[j]
            till = j
            break
        else:
            intnum[j] = 0
            intnum[-j-1] = 0
for j in range(till):
    intnum[-j-1] = intnum[j]
for m in intnum:
    print(m, end = "")
//