why am i getting only 46% accuracy.I replaced all " with " .What might be wrong then?
Chuk norris challenge doubt
Hey saurabh,
I donāt think you need to anything apart from just fetching the joke and making a csv.
Would you mind sharing your code on cb.lk/ide so that i can check where you r going wrong
Thanks
import requests
import json
url=āhttp://api.icndb.com/jokes/json?"
parameters={
āvalueā:ā"
}
r=requests.get(url,params=parameters)
print(r.url)
p=r.content
print(typeĀ§)
pa=json.loadsĀ§
print(type(pa))
m=pa[āvalueā]
print(m) #574 list elements
print(type(m))
print(type(m[0]))
print(m[0])
li=[int(xxx) for xxx in input("enter the id u wanna search- ").split()]
first_line=[āID,Jokeā]
filename=āchallengechuknorris.csvā
with open(filename,āwā,encoding=āUTF-8ā)as f:
HS=','.join(first_line)
HS+='\n'
f.write(HS)\
for i in range(574):
if(m[i]['id'] in li):
rs=""
h=m[i]['id']
g=m[i]['joke']
lii=[str(h),g]
rs=','.join(lii)
rs+='\n'
f.write(rs)
Hi,
look the first row of csv file you have generated. It has 3 columns. because the joke had comma in itself, and while converting to csv you have separated the string with , so it becomes a new column.
something like this : 1,Chuck Norris uses ribbed condoms inside out, so he gets the pleasure.
Instead i would recommend you to make a dataframe and use .to_csv() to convert into csv. It is much more cleaner than this way
Thanks
still cant figure cant.can u please do the required changes in the code above
Code is much cleaner now, If you donāt understand any line of code do let me know.
I hope this will help.
Thanks
what Test/ID.csv is being read?
How would you know which joke to submit out of 574.
So, we consider the x_test file, which is already provided to you. It means you need to get the jokes for only these number of ids that are mentioned in the ID.csv file
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.