Numeric ids for use in the survey

Need a way to link each question back to the source article in the survey output. Easiest way is to give each article a numeric id, and use that id in the Question ID in Qualtrics.

#open the current article content file and create a list from the titles
import json
from pprint import pprint

with open("wv_cs_ar_content_final.json") as fin:
    ar_content = json.load(fin)
    
title_list = list(ar_content.keys())
pprint(title_list)
['Will Self',
 'Andrew Michael Hurley',
 'Amanda Green',
 'Don Perata',
 'Hartford railway station',
 'Nicole Moudaber',
 'Jack (Homes novel)',
 'Revolution Muslim',
 "Tell The Wolves I'm Home",
 'Thomas Meehan (writer)',
 'Did You Ever Have a Family',
 'List of serial killers before 1900',
 'Cathy Marie Buchanan',
 'Opernpassage',
 '2016 Los Angeles Kiss season',
 'Yazoo and Mississippi Valley Railroad',
 'Uttar Pradesh',
 'Murder of Kelly Anne Bates',
 'The Queen of the Tearling',
 'Gary Rowett',
 'Kiss',
 'A Summer Bird-Cage',
 'Isabel Fonseca',
 'Francis Patrick Donovan']
#create a random ordered list of ints to use as ids for these 24 articles
from random import shuffle
list_of_ints = list(range(100, 100+len(title_list)))
shuffle(list_of_ints)

#add them to the article content dict
for i,t in enumerate(title_list):
    ar_content[t]['id'] = list_of_ints[i]

pprint(ar_content)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-70e46c804627> in <module>()
      6 #add them to the article content dict
      7 for i,t in enumerate(title_list):
----> 8     ar_content[t]['id'] = list_of_ints[i]
      9 
     10 pprint(ar_content)

TypeError: list indices must be integers, not str
#save the results for later
with open("wv_cs_ar_content_and_ids.json", "w") as fout:
    json.dump(ar_content, fout)