This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Michael O'Lynn
about 11 years

Can't pass 2.2 even though I am requiring the text, audio and image assets.

My code is:

from urllib2 import urlopen
from json import load, dumps

url = 'http://api.npr.org/query?apiKey=' 
key = 'API_KEY'
url = url + key
url += '&numResults=1&format=json&id=1007' #1007 is science
url += '&requiredassets="audio,text,image"'
response = urlopen(url)
json_obj = load(response)


#f = open('output.json', 'w')
#f.write(dumps(json_obj, indent=4))
#f.close()

for story in json_obj['list']['story']:
 print "TITLE: " + story['title']['$text'] + "\n"

I have required all the necessary assets, but I’m getting the error message Oops, try again. Great, you have requiredAssets Working. When you're ready, specify text, audio, and images to pass this exercise.

I can’t seem to figure out why I cannot pass though. Any ideas?

Answer 5122aa46a7a6335072003b86

4 votes

Permalink

Remove the double quotes around audio,text,images url += ‘&requiredassets=audio,text,image’

points
Submitted by Mike Ettestad
about 11 years

Answer 516ba4bfa553db45140013aa

2 votes

Permalink

url += '&requiredAssets=audio,text,image'
points
Submitted by 風一樣的男子
almost 11 years

Answer 510eb92be5cc899c2b0091cd

1 vote

Permalink

I tried code with spaces between the comma and the next requiredAsset and had to delete them inorder to pass to the next lesson.

points
Submitted by Michael B Fraser
about 11 years

Answer 50facac8bbb52d3205003bbe

0 votes

Permalink

Look at your capitalization .. requiredAssets .. not requiredassets :)

points
Submitted by Dave Smith
about 11 years

3 comments

Michael O'Lynn about 11 years

I’ve just tried i with the capital A, but no luck. I’m still getting the same error message.

Michael O'Lynn about 11 years

Never mind, I figured it out. I had audio,text,image in quotation marks for some reason. God knows what my brain was thinking when I wrote this.

Thanks for the help anyway Dave!

Dave Smith about 11 years

ok! I just noticed that you also had those in quotes .. doh! :)