Anuj Anuj - 1 year ago 92
Python Question

How to evaluate an expression in for loop using Python?

I want to evaluate an expression inside for loop. I am doing:

for i in range(0,255):
Q[i+1,1] = (np.floor_divide(i, q) * q + q/2)

but this returns an error saying

IndexError: index 1 is out of bounds for axis 1 with size 1".

Answer Source

The size is 256x1 but still you have to index with starting at 0. So you need Q[i,0]

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download