CrisofilaxDives / Python-Practica

Este es un repositorio de mis prácticas con Python, mis dudas y errores
1 stars 0 forks source link

print() all the items of a dictionary, Python 3.8.2 #1

Closed CrisofilaxDives closed 4 years ago

CrisofilaxDives commented 4 years ago

Hi, I'm new in python and I'm trying to print a dictionary that I made:

print( { "Mamifero":"Gato", "Reptil":"Lagartija", "Mamifero":"Perro", "Reptil":"Tortuga", "Reptil":"Serpiente", "Mamifero":"Koala" } )

But the Windows console only gave me this:

{'Mamifero': 'Koala', 'Reptil': 'Serpiente'}

How do I do to see all the elements using print()?

CrisofilaxDives commented 4 years ago

I understand where was my error. I'm learn something today and I create this as an example of a Dictionary:

dictionary_1 = {"animal":"gato", "numero_patas":4, "cola":True, "edad":3.6, "nombre":None}
print(dictionary_1)

for key, value in dictionary_1.items():
    print(key, "=", value)

And the Windows Console gave me this:

{'animal': 'gato', 'numero_patas': 4, 'cola': True, 'edad': 3.6, 'nombre': None}

animal = gato
numero_patas = 4
cola = True
edad = 3.6
nombre = None

Thank you very much.