cow = {
"data": [
{
"id": "1179640025492630",
"indicator": "google-analytics|UA-97996598-1",
"type": "API_KEY"
},
{
"id": "1469013519830038",
"indicator": "google-analytics|UA-96613605-2",
"type": "API_KEY"
},
{
"id": "1459958767410551",
"indicator": "google-analytics|UA-86399386-2",
"type": "API_KEY"
},
{
"id": "1507839102569000",
"indicator": "google-analytics|UA-89570367-2",
"type": "API_KEY"
},
{
"id": "1276736575767341",
"indicator": "google-analytics|UA-69774312-4",
"type": "API_KEY"
},
{
"id": "1292251910882451",
"indicator": "google-analytics|UA-93952538-3",
"type": "API_KEY"
}
],
"paging": {
"cursors": {
"after": "NQZDZD",
"before": "MAZDZD"
}
}
}
I want to extract the "id": "1179640025492630" from the data dictionary.
I have tried to use a for loop like:
for i in cow['data']:
for key,value in i:
if(i == 'id'):
print key,value
else:
pass
it gives me a value error like:
Traceback (most recent call last):
File "./dict.py", line 14, in <module>
for key,value in ['data']:
ValueError: too many values to unpack
And if I use .iteritems
I get an AttributeError
:
Traceback (most recent call last):
File "./dict.py", line 14, in <module>
for key,value in ['data'].iteritems:
AttributeError: 'list' object has no attribute 'iteritems'