I have a list in the form like this
[(x1,y0,output), (x1,y1,output), (x1,y2,output), (x2,y0,output), (x2,y1,output), (x2,y2,output)]
[(1, 0, 0), (1, 1, 1), (1, 2, 2), (2, 0, 0), (2, 1, 2), (2, 2, 4)]
I would like to get cells in the list with a specific condition.
For example,
I want all of the cells which x = 1
I hope the result is: [(1, 0, 0), (1, 1, 1), (1, 2, 2)]
I want all of the cells which x = 1, y = 2
I hope the result is: [(1, 2, 2)]
How can I do this?
import numpy as np
result = []
for x in np.arange(1, 3, 1):
for y in np.arange(0, 3, 1):
res = y * x
res = (x, y, res)
result.append(res)
print(result)