Issues with partitioning data
Code:
a = 100
b = 10
p = prime_range(a)
for j in range(a/b):
fn[j] = [(i,val) for i,val in enumerate(p) if j * b < p[i] < (j+1) * b];
My code is able to partition prime numbers up to 100 in decades, but when I try to increase the prime range limit, or increase the partition then the code breaks. I am not sure why that happens? Could it be the if statement?
How exactly it breaks? Please illustrate with an example.
Perhaps use
a//b
instead ofa/b
so that the argument torange
is an integer?Here is an error that I get. However, I am getting this error when a = 100, and b = 10.
IndexError Traceback (most recent call last)
<ipython-input-2-80f673aa11bb> in <module>()
----> 7 fn[j] = [(i,val) for i,val in enumerate(p) if jb < p[i] < (j+Integer(1))b];
IndexError: list assignment index out of range
I also tried the a//b, but that didn't work.