Some Jokes are missing from List

I have tried calling the APIS but many of them are missing so I am not able to execute the loop properly.

And I am not able to convert into CSV File

import requests

def get_joke(i):
surl=“http://api.icndb.com/jokes/
g=str(i)
url = surl+g
#print(url)
resp = requests.get(url)
resp.encoding = “utf-8”
data = resp.json()
print(data[“value”][“joke”])

for i in range(1,500):
if i==7 or i==8 or i==9 or i==10 or i==11:
continue
get_joke(i)

Hey,

test = pd.read_csv("Test/ID.csv").values.reshape(-1,)
jokes = []
for i in test:
    res = requests.get("http://api.icndb.com/jokes/{}".format(int(i)))
    joke = json.loads(res.content)['value']['joke']
    jokes.append(joke)

Just use this small piece of code and you are good to go… After this you just have to convert jokes into csv.
Thanks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.