This forum is now read-only. Please use our new forums at

1181 points
Submitted by
about 5 years ago

14/34: print paragraph text --why not paragraph[0]?

I'm a little confused about this line:

for paragraph in story['textWithHtml']['paragraph']:
    print paragraph['$text'] + "\n"

Why aren't we iterating over story['textWithHtml'][paragraph][0] since all the contents within the paragraph dictionary is encased in a list?


0 votes


Iterating through story['textWithHtml'][paragraph][0] would get the keys for the first paragraph. You want to iterate through all the paragraphs and extract the text.

If you look at the json object it may prove illuminating.

"paragraph": [
        "num": "1", 
        "$text": "foo"
        "num": "2", 
        "$text": "bar"
        "num": "32", 
        "$text": "baz"

880 points
Submitted by
Henry Baughman
about 5 years ago