I am making a simple sandwich-logging app in Python and I want to add an object like this:
"Sandwich A" : {
    "name" : "Sandwich A"
    "contents" : [
        "bread",
        "mayo",
        "bread"
    ]
}
Into this JSON file, right next to Sandwich B
{
    "Sandwiches" : {
        "Sandwich B" : {
            "name" : "Sandwich B"
            "contents" : [
                "bread",
                "butter",
                "bread"
]
        }
    }
}
through Python.
I've tried this, but it doesn't seem to work:
import json
with open('Example.json') as f:
    data = json.load(f)
    data["Sandwiches"][name] = {"name" : name, "contents" : contents}
Update: I tried this simpler version of my bigger app, but it still doesn't work
import json
def SandwichSteps():
    contents = []
    layer = input("    ")
    if layer == "end":
        return contents
    else:
        contents.append(layer)
        SandwichSteps()
with open('Sandos.json') as f:
    data = json.load(f)
    contents = SandwichSteps()
    name = input("name    ")
    data["Sandos"][name] = {"name" : name, "contents" : contents}
could you please explain what went wrong?
 
    