rows = range(1,4)
cols = range(1,3)
cells = [(row, col) for row in rows for col in cols]
print(cells)
cells = [(row, col) for row in rows if row !=2 for col in cols if col !=1]
print(cells)
Output :
[(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2)]
[(1, 2), (3, 2)]
Reference material :《Python Language and its application 》 Lubnovick Writing