I tried putting " around the jokes but instead of increasing efficiency it came down to 0.
Can you tell me the mistake?
My code:-
z=""
def helper(url,i):
global z
json_response=urlopen(url)
json_=json_response.read()
json_data=json.loads(json_)
#print(json_data)
e=""
if json_data[“value”]!=None and type(json_data[“value”])==dict :
e+=str(json_data[‘value’][‘id’])
e+=’,’
e+=(" "{} “,\n”.format(json_data[‘value’][‘joke’])[1:])
else:
e+=i
e+=’,’
e+=(json_data[‘value’])
e+=’,\n’
#print(z)
z+=e
t=""
with open(“ID.csv”,“r”) as f:
t=f.read();
f=t.split()
for i in f[1:]:
print(i)
url=“http://api.icndb.com/jokes/{}”.format(i)
helper(url,i)
print_head()
def print_head():
global z
with open(“chuck_norris.csv”,“w”) as f:
y=“ID,Joke,\n”
f.write(y)
with open(“chuck_norris.csv”,“w”) as f:
f.write(z)