I try to make program to find the length of the palindrome that can be made from a string in Python, but I got wrong result.
This is my program but I still get wrong results, maybe anyone can help me to fixed this.
from typing import Counter
def checkpalindrom(s):
mid = len(s)/2
end = len(s)-1
i = 0
while i<= mid:
if s[i]!= s[end-i]:
return False
return True
def deletepalindrom(s):
if deletepalindrom(s)==True:
return 0
min = 100
x = 0
while x < len(s):
temp = s
temp.remove(1)
Counter = deletepalindrom(temp)+1
if Counter<=min:
min = Counter
n = int(input())
for y in range(n):
s = input()
print(len(s)- deletpalindrom(s))
I got a redline in line print(len(s)- deletpalindrom(s))
to show the length and also in line temp.remove(1)
got 'str' object has no attribute 'remove'
.