data = [
(1, 2, 3),
(4, 5, 6),
(4, 5, 6),
(7, 8, 9)
]
X = [row for row in data if row[0] < 7]
Y = [row for row in data if row[1] == 5]
Z = [row for row in data if row[2] < 6 or row[2] > 6]
print("X:")
for row in X:
print(row)
print("Y:")
for row in Y:
print(row)
print("Z:")
for row in Z:
print(row)
ZGF0YSA9IFsKICAgICgxLCAyLCAzKSwKICAgICg0LCA1LCA2KSwKICAgICg0LCA1LCA2KSwKICAgICg3LCA4LCA5KQpdCgpYID0gW3JvdyBmb3Igcm93IGluIGRhdGEgaWYgcm93WzBdIDwgN10KWSA9IFtyb3cgZm9yIHJvdyBpbiBkYXRhIGlmIHJvd1sxXSA9PSA1XQpaID0gW3JvdyBmb3Igcm93IGluIGRhdGEgaWYgcm93WzJdIDwgNiBvciByb3dbMl0gPiA2XQoKcHJpbnQoIlg6IikKZm9yIHJvdyBpbiBYOgogICAgcHJpbnQocm93KQoKcHJpbnQoIlk6IikKZm9yIHJvdyBpbiBZOgogICAgcHJpbnQocm93KQoKcHJpbnQoIlo6IikKZm9yIHJvdyBpbiBaOgogICAgcHJpbnQocm93KQo=
X:
(1, 2, 3)
(4, 5, 6)
(4, 5, 6)
Y:
(4, 5, 6)
(4, 5, 6)
Z:
(1, 2, 3)
(7, 8, 9)