The following code should return the longest odd-length palindrome in a string centered at the index. So in a string 'asradarer' it should return 'radar'. Can you explain to me what the problem here is?
def get_odd_palindrome_at(word, index):
num = 1
new_word = ""
while index < len(word):
if word[index - num] == word[index + num]:
print new_word + word[index - num:index + (num + 1)]
num += 1
else:
print ""