← Lesson
Dictionaries
Joeven
Run
Reset
Python loads on first run
action = { "type": "tool", "name": "search", "args": {"q": "python lists", "k": 3}, } print("name:", action["name"]) print("thought or default:", action.get("thought", "")) print("nested q:", action["args"]["q"]) action["args"]["k"] = 5 print("updated k:", action["args"]["k"]) print("name in action?", "name" in action) print("thought in action?", "thought" in action) print("keys:", list(action.keys())) print("values:", list(action.values())) for key, value in action.items(): print("item:", key, value) missing = action.get("meta", {}).get("source") print("missing nested:", missing)
Run to execute this in your browser. Nothing is sent to a server.