Sep-06-2020, 05:29 AM
no need to check the key exists, just use
dict.get()
methodimport json def meaning(word, dictionary): return dictionary.get(word, "The word doesn't exist. Please double check it.") with open("data.json") as f: dictionary = json.load(f) word = input("Enter Word: ") print(meaning(word, dictionary))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs