Chuck Norries Joke Database
ICNDB is a fun database full of Chuck Norris jokes. If you’re a fan, it’ll be a while before you run out of Chuck Norris jokes again.
According to ICNDB, The phrase ‘break a leg’ was originally coined by Chuck Norris’s co-stars in Walker, Texas Ranger as a good luck charm, indicating that a broken leg might be the worst extent of their injuries. This never proved to be the case.
Here is a simply code that uses requests and json libraries:
Below code will fetch a single random joke:
import requests
import json
def chuck():
f = r"http://api.icndb.com/jokes/random"
data = requests.get(f)
tt = json.loads(data.text)
print(tt["value"]["joke"])
chuck()
Below code will fetch 5 random jokes:
import requests
import json
def chuck():
f = r"http://api.icndb.com/jokes/random/5"
data = requests.get(f)
tt = json.loads(data.text)
print(tt["value"]["joke"])
chuck()
Source of API: The Internet Chuck Norris Database
If you need a refresher on user defined functions lesson in Python here is a link to our Defining Functions Lesson.