title: Access string from dictionary value in Python
body: <p>I am trying to write a comprehension that, given two dictionaries (f, g), will return a dictionary whose key is the key of f, and whose value is the corresponding key's value of f of the value of g. For example, given:</p>
  
  <pre><code>f = {0: 'a', 1: 'b'}
  g = {'a': 'apple', 'b': 'banana'}
  my_function_composition(f, g) #returns {0: 'apple', 1: 'banana'}
  </code></pre>
  
  <p>My comprehension for some reason only outputs one character of the string</p>
  
  <pre><code>#output: {0: 'e', 1: 'a'}
  </code></pre>
  
  <p>Here is my function:</p>
  
  <pre><code>def my_function_composition(f, g):
      return {key: value for key in f for value in g[f[key]]}
  </code></pre>
  
  <p>Why is Python returning what seems to be the last character of the value string, rather than the entire string?</p>