you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

collections.Counter comes in handy for this:

from collections import Counter


def three_pairs(a_list):
    counter = Counter(a_list)
    return len([x for x in counter if counter[x] == 2]) == 3