I'm very new and I'm not sure if i'm just stupid but I thought it try and just ask. I created a list with all numbers from 2 up to n. Then it should start with the 2, cross out all the numbers that are divisible by to form the list. Then 3 do the same. 4 should be crossed off. 5 and so on. but 3 gets crossed off and the output list is all wrong and I can't figure out why.
here's my code
n=10
list = []
primes_up_to_n = []
p = 0
for z in range(n):
if z > 0:
list.append(z+1)
for i in list:
primes_up_to_n.append(i)
for t in list:
if t % i == 0:
list.remove(t)
print(primes_up_to_n)