this is my code:
from bs4 import BeautifulSoup as bs
import requests as rq
url = “http://api.icndb.com/jokes/json”
r = rq.get(url)
r_data = r.content
import json
json_data = json.loads(r_data)
jokes = json_data[‘value’]
print(jokes)
filename = “1chucknorris.csv”
with open (‘ID.csv’,‘r’) as f:
ids= f.read()
ids = ids.split()[1:]
with open(filename,‘w’) as f:
n = int(input("no. of jokes:- "))
count = 1
while count <= n:
for id in ids:
add_joke = jokes[id]['joke']
add_joke += '\n'
f.write(add_joke)
count += 1