What sort of help are you asking for?
The Sieve of Eratosthenes is a well-known, and very ancient, method of
generating prime numbers.
If you only want to solve the riddle, you can probably cheat by just
looking up the list of prime numbers:
Here is the Sieve again, with a couple of small bugs fixed:
x = x = 0 # 0 and 1 are not prime.
for i in range (2, n//2):
j = 2*i
while j < n:
x[j] = 0
j = j+i