dictionary within dictionary | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

dictionary within dictionary

Hi guys. I will be direct. How can I access keys or items within another key, that is, it is a dictionary within a dictionary. I will leave an example code. From now on, I am very grateful to anyone who can help me. compras = { 'frutas_joao': { 'pera': 50, 'uva': 2, 'maĆ§Ć£':55, 'abacaxi': 25, }, 'frutas_maria': { 'pera': 40, 'uva': 3, 'maĆ§Ć£':35, 'abacaxi': 15, },}

24th Apr 2021, 12:27 AM
Bia
Bia - avatar
1 Resposta
+ 5
print(compras["frutas_joao"]["pera"]) output: 50
24th Apr 2021, 12:38 AM
Slick
Slick - avatar