title: highest palindrome with 3 digit numbers in python
body: <p>In problem 4 from <a href="http://projecteuler.net/" rel="nofollow">http://projecteuler.net/</a> it says:</p>
  
  <blockquote>
    <p>A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.</p>
    
    <p>Find the largest palindrome made from the product of two 3-digit numbers.</p>
  </blockquote>
  
  <p>I have this code here </p>
  
  <pre><code>def isPalindrome(num):
      return str(num) == str(num)[::-1]
  def largest(bot, top):
      for x in range(top, bot, -1):
          for y in range(top,bot, -1):
              if isPalindrome(x*y):
                  return x*y
  print largest(100,999)
  </code></pre>
  
  <p>It should find the largest palindrome, it spits out <code>580085</code> which I believe to be correct, but project euler doesn't think so, do I have something wrong here?</p>
  
  <hr>
  
  <p>When I revered the for loop I didn't think it through, I removed the thing that checks for the biggest, silly me. Heres the working code</p>
  
  <pre><code>def isPalindrome(num):
      return str(num) == str(num)[::-1]
  def largest(bot, top):
      z = 0
      for x in range(top, bot, -1):
          for y in range(top,bot, -1):
              if isPalindrome(x*y):
                  if x*y &gt; z:
                      z = x*y
      return z
  print largest(100,999)
  </code></pre>
  
  <p>it spits out 906609</p>