old_contents: import json
  import random
  
  class Noah(object):
      def __init__(self, dictionary_file):
          self.dictionary = json.load(dictionary_file)
  
      def list(self):
          return '\n'.join([entry['word'] for entry in self.dictionary])
  
      def define(self, word):
          entry = next((x for x in self.dictionary if x['word'] == word), None)
  
          if not entry is None:
              return '%s (%s)' % (entry['word'], entry['part_of_speech'])
  
      def random(self):
          return(random.choice(self.dictionary))
  
  def main():
      with open('../dictionaries/english.json') as dictionary:
          n = Noah(dictionary)
  
      print n.list()
      print n.define('aardvark')
      print n.random()
  
  if __name__ == '__main__':
      main()
new_contents: import json
  import random
  import pprint
  
  class Noah(object):
      def __init__(self, dictionary_file):
          self.dictionary = json.load(dictionary_file)
  
      def list(self):
          return '\n'.join([entry['word'] for entry in self.dictionary])
  
      def define(self, word):
          return self.output(filter(lambda x: x['word'] == word, self.dictionary))
  
          if not entry is None:
              return self.output(entry)
  
      def random(self):
          return self.output(random.choice(self.dictionary))
  
      def output(self, data):
          return json.dumps(data, indent=4)
  
  def main():
      with open('../dictionaries/english.json') as dictionary:
          n = Noah(dictionary)
  
      print n.list()
      print n.define('run')
      print n.random()
  
  if __name__ == '__main__':
      main()
subject: Define returns all entries for given query.