title: Adding selective elements of one dictionary to another
body: <p>I have a list as:</p>
  <pre><code>my_list = [&quot;10&quot;, &quot;12&quot;, &quot;32&quot;, &quot;23&quot;]
  </code></pre>
  <p>and a dictionary as:</p>
  <pre><code>my_dict = {
      'one': {'index': 0, 'sec_key': 'AB', 'id': '10'},
      'two': {'index': 0, 'sec_key': 'CD', 'id': '12'}, 
      'three': {'index': 0, 'sec_key': 'EF', 'id': '32'}
      }
  </code></pre>
  <p>I want to keep a dictionary say final_dict which will have content of my_dict only if the id is present in my_list. I tried to do that by:</p>
  <pre><code>sf_dict = dict()
  
  for list_id in my_list:
      for key, value in my_dict.items():
          if list_id == value['id']:
              print(&quot;Values : {} {} {}&quot;.format(value['index'], value['sec_key'], value['id']))
              sf_dict[key] = key
              sf_dict[key]['index'] = value['index']  
              sf_dict[key]['sec_key'] = value['sec_key']
              sf_dict[key]['id'] = value['id']
          
  print(sf_dict)
  </code></pre>
  <p>I'm able to print the values but the assigning of those values is failing due to the error as:</p>
  <pre><code>TypeError: 'str' object does not support item assignment
  </code></pre>
  <p>Where am I making mistake?</p>