
def largestPalindrome(n):
  """
  :type n: int
  :rtype: int
  """
  number1 = ""
  number2 = ""
  for x in range(n):
    number1 += "9"
    number2 += "9"
  number1 = int(number1)
  number2 = int(number2)
  palindrome = 0
  for x in range(number1 + 1):
    for i in range(number2 + 1):
      product = x * i
      if (str(product) == str(product)[::-1]) and product > palindrome:
        palindrome = product
  return palindrome % 1337



n = 2
print(largestPalindrome(n))

def largestPalindrome(n):
  """
  :type n: int
  :rtype: int
  """
  number = ""
  for x in range(n):
    number += "9"
  number = int(number)
  palindrome = 0
  upper = number + 1
  lower = 0
  for x in range(upper, lower, -1):
    for i in range(upper, lower, -1):
      product = x * i
      if product < palindrome:
        break
      elif isPalindrome(product):
        palindrome = product
        upper = x
        lower = i
        break
  return palindrome % 1337

def isPalindrome(num):
  """ Return True is number is Palindrome, else return False """
  if str(num) == str(num)[::-1]:
    return True
  return False

n = 5
print(largestPalindrome(n))

Solve Largest Palindrome Product for range of n is
Solve Largest Palindrome Product for range of n is [1,6]

  
  def largestPalindrome(n):
    """
    :type n: int
    :rtype: int
    """
-   number1 = ""
+   number = ""
-   number2 = ""
    for x in range(n):
-     number1 += "9"
+     number += "9"
-     number2 += "9"
-   number1 = int(number1)
+   number = int(number)
-   number2 = int(number2)
    palindrome = 0
-   for x in range(number1 + 1):
-     for i in range(number2 + 1):
+   upper = number + 1
+   lower = 0
+   for x in range(upper, lower, -1):
+     for i in range(upper, lower, -1):
        product = x * i
-       if (str(product) == str(product)[::-1]) and product > palindrome:
+       if product < palindrome:
+         break
+       elif isPalindrome(product):
          palindrome = product
+         upper = x
+         lower = i
+         break
    return palindrome % 1337
  
+ def isPalindrome(num):
+   """ Return True is number is Palindrome, else return False """
+   if str(num) == str(num)[::-1]:
+     return True
+   return False
  
+ n = 5
+ print(largestPalindrome(n))
  
- n = 2
- print(largestPalindrome(n))
Solve Largest Palindrome Product for range of n is
## Code Before:

def largestPalindrome(n):
  """
  :type n: int
  :rtype: int
  """
  number1 = ""
  number2 = ""
  for x in range(n):
    number1 += "9"
    number2 += "9"
  number1 = int(number1)
  number2 = int(number2)
  palindrome = 0
  for x in range(number1 + 1):
    for i in range(number2 + 1):
      product = x * i
      if (str(product) == str(product)[::-1]) and product > palindrome:
        palindrome = product
  return palindrome % 1337



n = 2
print(largestPalindrome(n))
## Instruction:
Solve Largest Palindrome Product for range of n is
## Code After:

def largestPalindrome(n):
  """
  :type n: int
  :rtype: int
  """
  number = ""
  for x in range(n):
    number += "9"
  number = int(number)
  palindrome = 0
  upper = number + 1
  lower = 0
  for x in range(upper, lower, -1):
    for i in range(upper, lower, -1):
      product = x * i
      if product < palindrome:
        break
      elif isPalindrome(product):
        palindrome = product
        upper = x
        lower = i
        break
  return palindrome % 1337

def isPalindrome(num):
  """ Return True is number is Palindrome, else return False """
  if str(num) == str(num)[::-1]:
    return True
  return False

n = 5
print(largestPalindrome(n))
