free-dictionary.py 334 B

123456789101112131415
  1. #!/usr/bin/env python
  2. import requests
  3. import json
  4. query = "abababababab"
  5. data = requests.get(f"https://api.dictionaryapi.dev/api/v2/entries/en/{query}").json()
  6. try:
  7. print(f"""Searching the Dictionary for {query}
  8. Defintion: {data[0]["meanings"][0]["definitions"][0]["definition"]}
  9. """)
  10. except:
  11. print("No defintions found.")