Created
December 26, 2019 16:33
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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