So I have a Python file that contains a large set of data of nested dictionaries and lists that looks like this:
recipes = {
"recipe": {
"name": "solar_panel",
"type": "craft",
"ingredients": {
"input": [
"coal_dust",
"glass",
"coal_dust",
"glass",
"coal_dust",
"glass",
"electronic_circuit",
"generator",
"electronic_circuit"
],
"output": {
"item": "solar_panel",
"quantity": 1
}
}
},
"recipe": {
"name": "re_battery",
"type": "craft",
"ingredients": {
"input": [
"nothing",
"insulated_copper_cable",
"nothing",
"tin",
"redstone",
"tin",
"tin",
"redstone",
"tin"
],
"output": {
"item": "re_battery",
"quantity": 1
}
}
}
}
Then I have a Python script that is this
import vanilla
print(vanilla.recipes)
One would think that is would simply print the complete data structure, but in fact it prints only the last child item (lines 23-43 in the list). I feel like I am missing something obvious here.
It's because the key is the same - recipe
, so it saves only the last item in dictionary.
>>> {'a': 1, 'a': 2}
{'a': 2}