4 ms·
Or this (not efficient but fun, and using a dict comprehension and no itertools): {a: sum(a == b for b in colors) for a in set(colors)}
by aldanor 11y ago
Or this (not efficient but fun, and using a dict comprehension and no itertools):
{a: sum(a == b for b in colors) for a in set(colors)}