I'm probably doing something really dumb here, but I just wanted to test this bit of code to generate a list of the prime numbers from 2 to n; but I get an error message saying I haven't defined prime. But haven't I defined it in line 2? def sieve(n): prime = [2] for i in range(2, n + 1): for j in range(2, n + 1): if i % j == 0: pass else: prime.append(i) print prime