Q:

Convert numpy iterator to dictionary

I am iterating through two arrays with Numpy by following code
for position, force in np.nditer([positions,forces]):
    print("(x,y) = (%f,%f)" % (position, force))

but now I need it is a dictionary as
{
  1: "(x,y) = (2,3)",
  2: "(x,y) = (7,4)",
  3: "(x,y) = (1,2)",
  4: "(x,y) = (9,8)",
}

A:

You can create the dictionary with the help of enumerate within a dict comprehension :
{i: "(x,y) = (%f,%f)" % t for i, t in enumerate(np.nditer([positions,forces]), 1)}

