I am trying to write the joke and id in the .csv file but as soon as the part start running the python server shows busy.
Here is my code
#‘http://api.icndb.com/jokes/1’
import requests
import json
with open(“ID.csv”,“r”) as file:
ids=(file.readlines())
print(ids)
with open(“output.csv”,“w”) as file:
file.write(“ID,Joke\n”)
result=""
for id in ids[1:]:
joke_url=f’http://api.icndb.com/jokes/{id}’
response=requests.get(joke_url)
data=json.loads(response.content)
result+="{},".format(idx)+","+data[‘value’][‘joke’]+"\n"
file.write(result)
Please reply as soon as possible.