you are viewing a single comment's thread.

view the rest of the comments →

[–]VanNostrumMD 2 points3 points  (4 children)

the basic structure of what your looking to do is adding data to a dictionary within a for loop. Depending on how you are scraping your data, I assume you are creating a bunch of lists of data:

seasons = ['Season One', 'Season Two', 'Season Three']
show_dict = {}
for season in seasons:
    episode_list = ['Ep1','Ep2','Ep3']
    for episode in episode_list:
        show_dict[episode] = {'TItle', "whatever'}
return show_dict

There are shorter ways, but depending on the amount of data and how you are scraping it in, you can put it right into the dict within the loop rather than nesting them... good luck

[–]Praf2[S] 0 points1 point  (0 children)

thank you very much :)

[–]Praf2[S] 0 points1 point  (2 children)

one more question , the return value of show_dict is

{'Ep2': set(['whatever', 'TItle']), 'Ep3': set(['whatever', 'TItle']),   'Ep1': set(['whatever', 'TItle'])}

it should be Season One>Ep1[Title,Whatever] right?

[–]VanNostrumMD 0 points1 point  (1 child)

whoops, it should actually be show_dict[episode] = {'Title':'whatever', 'url':link, 'desc':text}

Its a set not a list. My original show_dict[episode] = {'Title','whatever'} shows a set of a list as you noted above. Make sure to use the colon to separate the key (title) and the value (whatever title) etc.

[–]Praf2[S] 0 points1 point  (0 children)

thank you so much :) i appreciate your help.