Interactive dictionary with inexact lookups (step 1) I'm currently building an interactive dictionary. I'm using a sample JSON file (i.e. data.json) as a template. But that's not it. My aim is to build an app where I can store the knowledge that I acquire during my learning process.

And I'd like you to take a look at my code to see if there are areas where I can improve the performance of my program.

Code

import json
from difflib import get_close_matches

data = json.load(open('data.json', 'r'))

def newdict(word, definition):
    data.update({word: [definition]})
    with open('data.json', 'w') as file:
        json.dump(data, file)


def tr(word):
    gcm = get_close_matches(word, data, 1, 0.8)
    if word in data:
        print('· ' + word + ':')
        for index, definition in enumerate(data[word]):
            print(str(index+1) + '.', definition)
    elif word.title() in data:
        print('· ' + word.title() + ':')
        for index, definition in enumerate(data[word.title()]):
            print(str(index + 1) + '.', definition)
    elif word.upper() in data:
        print('· ' + word.upper() + ':')
        for index, definition in enumerate(data[word.upper()]):
            print(str(index + 1) + '.', definition)
    elif len(gcm) &gt; 0:
        print('· ' + gcm[0].capitalize() + ':')
        for index, definition in enumerate(data[gcm[0]]):
                print(str(index+1) + '.', definition)
    else:
        print("'%s' definition isn't available at the moment." % word.capitalize())
        x = input('Would you like to add "%s" to the dictionary? ' % word.capitalize())
        x = x.lower()
        if x == 'yes':
            y = input('Type in the meaning of %s: ' % word)
            newdict(word, y)
        else:
            print('Ok, as you wish!')

w = input('Enter a word: ')
w = w.lower()
while w != '0':
    tr(w)
    w = input('\nEnter a word: ')
    w = w.lower()


Is there room for improvement?
The biggest thing that jumps out at me is that your project isn't in the form of a class, it's a function. This is, while not quite discouraged, certainly non-advantageous. Classes make things more portable. If I were building this, I'd structure it something like this:

class fuzzydict:
  """Fuzztdict: A dictionary with inexact lookups
       #Function definitions, etc go here.
  """
  def __init__(self):
    #Create the data file, initialize all your other variables.
  def __str__(self):
    #This one isn't necessary, but it would allow you to customize what would happen when you call print on a fuzzydict.
  def find_word(self,word):
    #Find a word in the dictionary, or report that it (probably) doesn't exist.
  def add_word(self,word,definition):
    #Add a word to the dictionary. 


Then, you'd instantiate it with newDict = fuzzydict() and you'd be good to go. You can use stuff like newDict.find_word('apple'), which is a much more intuitive interface than your while loop.

A few other things about your code:


You're checking various versions of your data in the JSON. Do you intend to eventually be able to input data yourself? Then I'd suggest formatting your entries into all UPPER or all lower case, then including how they were originally inputted as an attribute for that entry. This'll eliminate the multiple checks. 
Error handling. The difference between a good program and a truly epic program is how gracefully it can recover from something it didn't expect. 
As stated in other answers, document. Document, document, document. Even when it's just a particularly interesting way of doing something, make your code as descriptive as possible. Future you will thank you, as well as anybody else who tries to decipher the finished project. Remember docstrings, they're a gift from whatever deities the creators of Python worship.