Simple Dictionary Mini Project Python

In this post, we will be creating Simple Dictionary Mini Project using Python that will not only allow the user to type in words to get meaning but also provide word suggestions in the case of a misspelling.

Build Simple Dictionary Mini Project Python

To Build Simple Dictionary Simulator You need to follow the below steps

Step 1. Download Python

You only need Python to run this script. You can visit here to download Python.

Step 2. Write the following code

Write this code in a Python file or directly copy this code and save the file with the name and .py extension e.g python

import json
from difflib import get_close_matches
data = json.load(open("data.json"))

def translate(word):
    word = word.lower()
    if word in data:
        return data[word]
    elif word.title() in data:
        return data[word.title()] 
    elif word.upper() in data:
        return data[word.upper()]
    elif len(get_close_matches(word, data.keys())) > 0:
        print("did you mean %s instead" %get_close_matches(word, data.keys())[0])
        decide = input("press y for yes or n for no: ")
        if decide == "y":
            return data[get_close_matches(word, data.keys())[0]]
        elif decide == "n":
            return("pugger your paw steps on working keys ")
            return("You have entered wrong input please enter just y or n")    
        print("You have entered wrong keys. Try again")

word = input("Enter the word you want to search: ")
output = translate(word)
if type(output) == list:
    for item in output:

After copying this code also add the following Data.json file to your Project. Click here to download JSON File.

Step 3. Run the code

After saving the code double-click on the file to run the program or simply open Command Prompt and write the following command.

python python


Simple Dictionary Mini Project Python