Дано
import operator as op
d = {
"22": [
("22_0", ["A", "B", "C", "D"]),
("22_1", ["B", "C", "D", "E"]),
("22_2", ["A", "B", "C"]),
],
"33": [
("33_0", ["A", "B", "C", "D"]),
("33_1", ["A", "B", "C", "D"]),
("33_2", ["A", "B", "C", "D"]),
]
}
Код
def all_equal(seq):
"""Return True if all elements are equal."""
return len(set(seq)) == 1
def get_items(seq, index=1):
"""Return nested elements at index."""
idx = op.itemgetter(index)
return [idx(x) for x in [idx(lst) for lst in seq]]
Демо
[all_equal(get_items(x)) for x in d.values()]
Подробности
Функциональный эквивалент:
def idx_1(seq):
"""Return the element at index 1."""
return seq[1]
get_items = lambda x: map(idx_1, map(idx_1, x))
second_vals = map(get_items, d.values())
list(map(all_equal, second_vals))
# [False, True]