Explica este c贸digo Python
Dificultad: Intermedio
person = {}
person['fname'] = 'Joe'
person['lname'] = 'Fonebone'
person['age'] = 51
person['spouse'] = 'Edna'
person['children'] = ['Ralph', 'Betty', 'Joey']
person['pets'] = {'dog': 'Fido', 'cat': 'Sox'}
print(person.get("pets").get("cat"))
馃憠 A. Fido
馃憠 B. Sox
馃憠 C. SyntaxError
馃憠 D. TypeError
馃憠 B. Los diccionarios pueden contener otros diccionarios en su interior. Esta sintaxis se llama diccionario anidados y para acceder a sus valores se debe concatenar m茅todos Nota tambi茅n como creamos el diccionario, inicialmente
Respuesta:
Sox
get()
(como en este reto) o se puede usar tambi茅n la sintaxis de corchete:
print(person["pets"]["cat"]) # Sox
person
es un diccionario vac铆o y lo vamos llenando propiedad a propiedad asignado valores a diferentes claves.