Mar-02-2022, 06:47 AM
You could use a dictionary
from collections import defaultdict d = defaultdict(complex) for c, name, n in mylist: d[name] += c * c print(d)