Given:
di1={1: [1, 1, 1], 2: [1, 1, 1], 3: [1, 1, 1]}
di2={1: [1, 1, 1], 2: [1, 1, 1], 3: [1, 2, 1]}
di3={1: [1, 2, 1], 2: [1, 2, 1], 3: [1, 2, 1]}
di4={1: [1, 1, 2], 2: [1, 2, 1], 3: [1, 2, 1]} # same but different order
If the order of the items in the lists does not matter, you can make a set of frozensets that will show if they are all the same values, regardless of order:
for d in (di1,di2,di3, di4):
print(d)
print(len({frozenset(e) for e in d.values()})==1)
Prints:
{1: [1, 1, 1], 2: [1, 1, 1], 3: [1, 1, 1]}
True
{1: [1, 1, 1], 2: [1, 1, 1], 3: [1, 2, 1]}
False
{1: [1, 2, 1], 2: [1, 2, 1], 3: [1, 2, 1]}
True
{1: [1, 1, 2], 2: [1, 2, 1], 3: [1, 2, 1]}
True
If the order of the lists is relevant (ie, di4
should be False
), you can use a set of tuples instead of a set of frozensets:
for d in (di1,di2,di3, di4):
print(d)
print(len({tuple(e) for e in d.values()})==1)
Prints:
{1: [1, 1, 1], 2: [1, 1, 1], 3: [1, 1, 1]}
True
{1: [1, 1, 1], 2: [1, 1, 1], 3: [1, 2, 1]}
False
{1: [1, 2, 1], 2: [1, 2, 1], 3: [1, 2, 1]}
True
{1: [1, 1, 2], 2: [1, 2, 1], 3: [1, 2, 1]}
False
{1: [1, 1, 1], 2: [2, 2, 2]}