TLE in "Longest Palindrome" (LONGPALI)

I have submitted following code for the Longest Palindrome problem:

def isPalin(s):
  if s == s[::-1]:
    return True
  else:
    return False

def getResult(n, s):
  for l in range(n, 0, -1):
    for i in range(n-l+1):
      if isPalin(s[i:i+l]):
        print(len(s[i:i+l]), s[i:i+l], sep='\n')
        return

n = int(input().strip())
s = input().strip()

getResult(n, s)

But, this is a basic approach and can be optimized further to improve execution time. Kindly help.

It is common to happened TLE. Look at your code. This problem require highest 2 sec for submission. So, your solution should be O(n^2) formation. But you use a function inside the loop which has also 2 for loop inside.