Writing an algorithm to generate prime numbers in Python within a given range
<p>I see that there are many different ways to generate prime numbers. My code is very long and redundant but I know it can definitely be condensed and made less repetitive with a few changes and I was hoping I could be pointed in the right direction. Essentially I would like to automate the process that is being shown in my code so it can work for any range and all prime numbers.</p>

<p>Here is my code:</p>

<pre><code>def primes():
    multiplesList1 = []
    multiplesList2 = []
    multiplesList3 = []
    multiplesList4 = []
    multiplesList5 = []
    multiplesList6 = []
    multiplesList7 = []
    multiplesList8 = []
    multiplesList9 = []
    for i in range(2,1000):
        if i % 2 != 0 or i == 2:
            multiplesList1.append(i)
    for j in multiplesList1:
        if j % 3 != 0 or j == 3:
            multiplesList2.append(j)
    for x in multiplesList2:
        if x % 5 != 0 or x == 5:
            multiplesList3.append(x)
    for y in multiplesList3:
        if y % 11 != 0 or y == 11:
            multiplesList4.append(y)
    for z in multiplesList4:
        if z % 13 != 0 or z == 13:
            multiplesList5.append(z)
    for a in multiplesList5:
        if a % 17 != 0 or a == 17:
            multiplesList6.append(a)
    for b in multiplesList6:
        if b % 19 != 0 or b == 19:
            multiplesList7.append(b)
    for c in multiplesList7:
        if c % 23 != 0 or c == 23:
            multiplesList8.append(c)
    for d in multiplesList8:
        if d % 29 != 0 or d == 29:
            multiplesList9.append(d)
    return multiplesList9

print(primes())
</code></pre>