title: Performing calculations on some values in a dictionary based on their keys (Python)
body: <p>Looking to gain some understanding on handling dictionaries efficiently in Python.</p>
  
  <p>I have a dictionary</p>
  
  <pre><code>dict = {'a': 11, 'b': 4, 'c': 7, 'd': 12, 'e': 5}
  </code></pre>
  
  <p>and I would like to <strong>perform calculations only on a subset of its values</strong>. Which values to be considered in the calculations is <strong>based on their keys</strong>. Say, that these keys will be in a list of keys.</p>
  
  <p>For example, if I would like to add the values of the keys <code>a</code>, <code>b</code> and <code>e</code> (i.e. <code>keys_list_to_add</code>=['a', 'b', 'e']) I would expect the result to be <code>20</code>. Note, that several such subsets calculations may exist and a key may be missing (so, perhaps an exception should be raised in that case).</p>
  
  <p>After seeing this <a href="https://stackoverflow.com/a/5352630/6167676">answer</a>, I tried to implement it with no success cause I am still learning Python. Could you please provide with code suggestions for my problem?</p>