I’m trying to use Python to search a json by its value, not its variable.
Basically: I want ot search .a json file for the string/second vaue and return the first value
I’m making a stenography game, and I’m trying to do this so I can search for the strokes by the word.
For example:
“TKPWRAOEUPBD”: “grind”
I search “grind” and it returns “TKPWRAOEUPBD”. Or I search for another word, let’s say, “hello”, and it returns the correct value, which would be “H-L”, for my personal dictionary.
I’ve tried this:
import json
x = open("main.json")
y = x.read()
z = json.loads(y)
print(z["VALUE HERE"])
But it only lets me do the raw strokes, not any words.
aqwek_ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.