title: Replace a string stored in a list of dictionaries
body: <p>I'm developing a program in python3 and need to iterate over a list of dictionaries and replace all occurances of a specific character '-' to '_'. Ideally, I only need to replace instances of '-' in dictionary keys, but I can manage otherwise</p>
  
  <p>data is in the following format:</p>
  
  <pre><code>d=[
      {
      'title': [('Agente 007, Moonraker: Operazione spazio', 'it')], 
      'sub-title': [('Missione nel cosmo per...', 'it')], 
      },{
      'title': [('Agente 007, Vivi e lascia morire', 'it')], 
      'sub-title': [('Il primo James Bond con...', 'it')]
      }
    ]
  </code></pre>
  
  <p>I tried replacing it as you would a string with:</p>
  
  <pre><code>d.replace('-','_')
  </code></pre>
  
  <p>But that gave error:</p>
  
  <pre><code>AttributeError: 'list' object has no attribute 'replace'
  </code></pre>
  
  <p>Then I figured I'd iterate over the list and dictionary items to try and replace:</p>
  
  <pre><code> for i in range(len(dicts)):
       for x in dicts[i].items():
           dicts[i].items.replace('-','_')
  </code></pre>
  
  <p>which gave me </p>
  
  <pre><code> AttributeError: 'builtin_function_or_method' object has no attribute 'replace'
  </code></pre>
  
  <p>So now I'm trying</p>
  
  <pre><code>def t(dicts):
      for i in range(len(dicts)):
          for key in dicts[i].items():
              dicts[i].items()[key.replace('-','_')] = (dicts[i].items()).pop(key)
  </code></pre>
  
  <p>however, that gives error:</p>
  
  <pre><code>AttributeError: 'dict_items' object has no attribute 'pop'    
  </code></pre>
  
  <p>Does anybody know how to do this? And if it's something I'm doing wrong, what would be the <strong>correct</strong> method of going about this?</p>