Skip to content

Instantly share code, notes, and snippets.

@rahulnegi20
Created May 19, 2021 15:05
Show Gist options
  • Save rahulnegi20/fb994003f31884dbc1bdb82a000a1ebe to your computer and use it in GitHub Desktop.
Save rahulnegi20/fb994003f31884dbc1bdb82a000a1ebe to your computer and use it in GitHub Desktop.
def get_synonyms(title):
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('\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ SYNONYMS of {} \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n'.format(title))
for x in range(3):
print(result[0]["meanings"][0]["definitions"][0]["synonyms"][x])
except :
print('!!Error!! ', sys.exc_info()[0])
os._exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment