Write a program to choose a CATEGORY from the LIST and get the value for the same.
https://api.chucknorris.io/
https://api.chucknorris.io/jokes/categories
https://api.chucknorris.io/jokes/random?category=animal
Code : cat sample.py
import requests
get_data = requests.get("https://api.chucknorris.io/jokes/categories")
print(get_data)
output = get_data.json()
print("List of the categories " , output)
get_input = input("Choose any one : ")
mydata = requests.get(f"https://api.chucknorris.io/jokes/random?category={get_input}")
#print(mydata)
myjson = mydata.json()
myjson1 = myjson["value"]
print(myjson1)
Output : sample.py
<Response [200]>
List of the categories ['animal', 'career', 'celebrity', 'dev', 'explicit', 'fashion', 'food', 'history', 'money', 'movie', 'music', 'political', 'religion', 'science', 'sport', 'travel']
Choose any one : dev
Chuck Norris's log statements are always at the FATAL level.
Top comments (0)