Skip to content

Instantly share code, notes, and snippets.

@singlerider
Created May 12, 2015 06:56
Show Gist options
  • Save singlerider/4a6e323be48b3ff58670 to your computer and use it in GitHub Desktop.
Save singlerider/4a6e323be48b3ff58670 to your computer and use it in GitHub Desktop.
import requests
import json
def urban(args):
word = args[0].replace(' ','%20')
word_url = 'http://api.urbandictionary.com/v0/define?term=' + word
word_resp = requests.get(url=word_url)
translated_word = json.loads(word_resp.content)
found_word = translated_word['list'][0]['word']
definition = translated_word['list'][0]['definition']
example = translated_word['list'][0]['example']
intended_output = "Definition for {}: {}. Example: {}".format("found_word,definition,example")
return intended_output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment