I can't seem to extract specific data from JSON which I retrieved from a link.
I wrote this code and seems to work fine up to x
[print(x)
that is] as you can see from the screenshot-1.
But, it's giving errors while executing the last 2 lines. [Screenshot-2] I saw this from a video on youtube and tried it on my own.
Maybe I am making a mistake somewhere, Can anybody please tell me where am I doing wrong?
Code:
import json
import urllib.requestconnection = urllib.request.urlopen('http://py4e-data.dr-chuck.net/comments_42.json')
js = connection.read()
pj = json.loads(js)
x = json.dumps(pj,indent = 2)
#print(x)for z in x:print(z["count"])
[] [screenshot-1]
[] [Screenshot-2]