Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created December 26, 2019 16:33
Show Gist options
  • Save Fhernd/958cdb05fa3c2a3dd6ba29f5e48ffcfb to your computer and use it in GitHub Desktop.
Save Fhernd/958cdb05fa3c2a3dd6ba29f5e48ffcfb to your computer and use it in GitHub Desktop.
# Ejercicio 434: Crear un objeto diccionario a partir de una lista de objetos tupla.
# Ejercicio 434: Crear un objeto diccionario a partir de una lista de objetos tupla.
lista_tuplas = [('a', 1), ('b', 2), ('a', 2), ('b', 3), ('c', 1), ('e', 5), ('c', 2), ('b', 1), ('b', 5)]
d = {}
for x, y in lista_tuplas:
d.setdefault(x, []).append(y)
print(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment