Sto cercando di sommare una lista di contatori in python. Ad esempio, per riassumere:Elenco sommario di contatori in python
counter_list = [Counter({"a":1, "b":2}), Counter({"b":3, "c":4})]
che invia Counter({'b': 5, 'c': 4, 'a': 1})
posso ottenere il seguente codice di fare la somma:
counter_master = Counter()
for element in counter_list:
counter_master = counter_master + element
Ma io sono confusa sul motivo per cui counter_master = sum(counter_list)
genera l'errore TypeError: unsupported operand type(s) for +: 'int' and 'Counter'
? Dato che è possibile aggiungere contatori insieme, perché non è possibile sommarli?