Project Euler #4 repeat of numbers generated
<p>I was trying to solve Project Euler Problem #4 and while I have solved it I am not satisfied with my code because it generates repeats.</p>

<p>Below is the code:</p>

<pre><code>pal = []

for i in range(100 ** 2, 1000 ** 2):
    if str(i) == str(i)[::-1]:
        pal.append(i)

for n in pal:
    for x in range(100, 1000):
        if 99 &lt; n / x &lt; 1000 and n % x == 0:
            print(x, n//x, n)

# largest palindrome product of two 3-digit numbers
</code></pre>

<p>When I run this code, I get repeats ie. multiples of the same palindrome product. For example, it will return 840048 twice, which is a product of 888 and 946. Is there a way to not generate repeats with this code?</p>

<p>EDIT 1: part of my build output</p>

<pre><code>946 888 840048
869 982 853358
982 869 853358
894 957 855558
957 894 855558
924 932 861168
</code></pre>

<p>You could you <code>set</code> or to store values just once:</p>

<pre><code>pal = set()

for i in range(100 ** 2, 1000 ** 2):
    if str(i) == str(i)[::-1]:
        pal.add(i)

for n in pal:
    for x in range(100, 1000):
        if 99 &lt; n / x &lt; 1000 and n % x == 0:
            print(x, n//x, n)
</code></pre>

python python-3.x