by Phantom Wolf on Sun Jul 31, 2011 1:25 pm
([msg=60378]see Re: Euler #3[/msg])
Your indentation was outright wrong. You should always use four spaces and absolutely no tabs. If you haven't already, I suggest reading PEP 8.
To address your problem, it always printed out the result of the last sequence because you wire directly assigning the result to L each time. So, every time the loop ran, the old result was forgotten. I fixed this by making L into a list, and appending the result each loop. That way, all the results are remembered.
- Code: Select all
L = []
for x in range(100, 1000):
for y in range(100, 1000):
product = x*y
if str(product) == str(product)[::-1]:
L.append(product)
print max(L)
"Well it isn't my fault. I shouldn't have been allowed to do something to crash it." "No, you shouldn't have been allowed to buy a computer in the first place"