Colección de citas famosas - Colección de poesías - Cómo agregar valores en un diccionario
Cómo agregar valores en un diccionario
& gt& gt& gtmydict = {}
& gt& gt& gtalst = [('A ', 20), (' A ', 30)]
& gt& gt& gtfor alst k, v:
...mydict.setdefault(k, 0)
...mydict[k] += v
...
& gt& gt& gtMi diccionario
{'A': 50}
& gt& gt& gt