Index Error , List index out of range
In "if" statement, the second line gives the above specific error
You can see the value of index(ind) being used for the list(temp). It is clearly not out of range but it still gives the error.
def longestPalindrome(s):
n = 0
e = 1
temp = []
l = []
x = []
length = []
ind = 1
for i in range(1,len(s)+1):
temp.append(i)
while [] not in x:
l = s[n:e]
if n == len(s):
n=0
e = temp[ind]
ind = ind+1
l = s[n:e]
if l[::1] == l[::-1]:
x.append(l)
length.append(len(l))
elif l[::1] == l[::-1]:
x.append(l)
length.append(len(l))
n = n+1
e = e+1
return x[length.index(max(length))]