This forum is now read-only. Please use our new forums! Go to forums
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
Remove the double quotes around audio,text,images url += ‘&requiredassets=audio,text,image’
Answer 516ba4bfa553db45140013aa
Answer 510eb92be5cc899c2b0091cd
1 vote
I tried code with spaces between the comma and the next requiredAsset and had to delete them inorder to pass to the next lesson.
Answer 50facac8bbb52d3205003bbe
0 votes
Look at your capitalization .. requiredAssets .. not requiredassets :)
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
3 comments
I’ve just tried i with the capital A, but no luck. I’m still getting the same error message.
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!
ok! I just noticed that you also had those in quotes .. doh! :)