# Revision history [back]

You didn't tell us about the line fn = [] before. That makes it a list of length 0, and fn[j] = ... tries to assign to other entries of that list. You could do any of these:

a = 100
b = 10
p = prime_range(a)
fn = []

for j in range(a/b):
fn.append([(i,val) for i,val in enumerate(p) if j * b < p[i] < (j+1) * b])


or

a = 100
b = 10
p = prime_range(a)
fn = [[(i,val) for i,val in enumerate(p) if j * b < p[i] < (j+1) * b] for j in range(a/b)]


or

a = 100
b = 10
p = prime_range(a)
fn = {}

for j in range(a/b):
fn[j] = [(i,val) for i,val in enumerate(p) if j * b < p[i] < (j+1) * b]