PYTHON - DAY 1.1 - my DOODLE

technonotes-hacker - Feb 25 - - Dev Community

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

Image description

https://api.chucknorris.io/jokes/random?category=animal

Image description

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)

Enter fullscreen mode Exit fullscreen mode

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.

Image description

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player