Skip to content

Instantly share code, notes, and snippets.

@rahulnegi20
Last active May 17, 2021 11:54
Show Gist options
  • Save rahulnegi20/5f671a8d656885bf7cc1791f4c04ded0 to your computer and use it in GitHub Desktop.
Save rahulnegi20/5f671a8d656885bf7cc1791f4c04ded0 to your computer and use it in GitHub Desktop.
def get_meaning(title):
"""
This function will return the meaning of the word
"""
try :
url = 'https://api.dictionaryapi.dev/api/v2/entries/en_US/'+title
result = json.load(urllib.request.urlopen(url))
except urllib.error.HTTPError as e: ResponseData = 'failed'
except :
print('Connect to Internet!!', sys.exc_info()[0])
os._exit(0)
try :
print('\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ MEANING of {} \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n'.format(title))
print(result[0]["meanings"][0]["definitions"][0]["definition"])
print('\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\END\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n')
except :
print('!!Error!! Please Check the Spelling!', sys.exc_info()[0])
os._exit(0)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment