Q:

Associating the key in one dictionary to the values in another dictionary

I have two dictionaries. 1 of them shows people and activities they like. 
my_dict= {'bob': ['skiing',
  'soccer',
  'ballet'],
 'Angela': ['skiing',
  'ballet',
  'hiking'] }

and so on... 
The other dictionary shows the number of people in each activity, like so:
my_dict1= {'skiing': 5,
 'soccer': 8,
 'ballet': 33,
 'hiking': 2 }

and so on... 
I would like the resulting dictionary to look like this: 
my_dict= {'bob': 46,
 'Angela': 40 }

I need to assign the value of my_dict1 to the associated value in my_dict. Then I need to sum them. For example, 'bob': 46 is derived from 'bob': 5+8+33

A:

my_dict= {'bob': ['skiing',
  'soccer',
  'ballet'],
 'Angela': ['skiing',
  'ballet',
  'hiking'] }

my_dict1= {'skiing': 5,
 'soccer': 8,
 'ballet': 33,
 'hiking': 2 }

new_dic ={}

for i in my_dict:
    new_dic[i]=sum([my_dict1[i] for i in my_dict[i]])

print(new_dic)

