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

0 points
Submitted by Robert
about 9 years

This exercise has a problem with some stories being returned by NPR

The story that I retrieved (id 384043661, which was the most recent story in feed 1007) had empty dicts for:

story['image'][0]['caption']
story['image'][0]['producer']

The exercise can’t be completed because we receive a key error for ‘$text’ with the empty dicts. We can’t change the number of results from 1, and we can’t change the id to a different feed or story in order for the grader to accept.

Also, the instructions contain a mistake (perhaps the API has changed since it was written).

On another line, check to see if ‘caption’ is in story

In the current api: json_obj['list']['story']['caption'] never exists. It should be if 'caption' in story['image'][0]

Please change this exercise to use a hard-coded story id, such as 376184710, which has all of the required fields, in order to eliminate the intermittent problem users have where the most recent story fails.

Exercise 14/34 also fails, probably for the same reason - it needs the output of 13/34 to be correct.

Thank you!

Answer 54ee1e12d3292f2c730002cd

0 votes

Permalink

Anyone else having the problem - here’s how I solved it to fool the grader. The exercise still needs to be fixed though.

url += '&requiredAssets=text'

It may or may not work for the most recent story in id 1007 when you run it. I get an error when it tries to read data for the MP3 audio, but the grader passes it anyway.

points
Submitted by Robert
about 9 years