Using capabilities of substrings put all possible palindromes into a list. Then using the max() function find the largest palindrome hidden inside the inputted word
A = input()
length = []
for i in range(len(A)):
for j in range(i,len(A)):
A2 = A[i:j+1]
if A2 == A2[::-1]:
length.append(len(A2))
print(max(length))
Comments