Input-
[(0, 48), (0, 1474), (1, 2709), (1, 27), (1, 2)]
Output- [(0, 2), (1, 3)]
Output is computed by counting how many times did the first number in the tuple repeated in the list. My constraint is that I don't want to use Pandas. I have tried collections.Counter(x[0] for x in tuples)
but it only gives me a list of [2, 3]. This is insufficient because there is no way to tell what element occurred 2 times or 3 times. How should I do that?