myList = [(0, 2), (1, 3), (2, 4), (0, 5), (1, 6)]
sorted_ = sorted(myList, key=itemgetter(0))
grouped = groupby(sorted_, key=itemgetter(0))
numbers = [[t[1] for t in items] for _, items in grouped]
muls = [mul(items) for items in numbers if len(items) > 1]
print(sum(muls))
python sum tuple list based on tuple first value