hello i have this piece of python3 code with a piece of thejson code as well im havi 5122401
Hello, I have this piece of python3 code with a piece of thejson code as well. Im having an error when i try to pop/remove aspecfic object from the json file. In this case i want to removethe first object from the json file. However it is givin me anerror. I have tried using pop, remove, and del and it does notwork. I also want to modify that part of the json object that iremoved and put it back in the original location. Btw state isalready defined, This is just a part of a code. with open(“flightsdata.json”) as f: data = json.load(f) for state in data[“cities”]: origin = state[‘name’][0] destination = state[‘name’][1] price = state[‘price’] seats = 48 seats = state[‘seats’] if where == destination: my_flight_data = state data.pop(state) break { “cities”: [{ “name”: [“DER”,”LEA”], “seats”: [ [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0] ], “price”: 450 This is the error Im getting: File “serverTravel.py”, line 339, in buyTickets
data.pop(state)
TypeError: unhashable type: ‘dict’ . . .