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 Antwort
+ 5
print(compras["frutas_joao"]["pera"]) output: 50
24th Apr 2021, 12:38 AM
Slick
Slick - avatar