title: Rename dictionary keys/values in python
body: <p>What I'm trying to do is this. I have a dictionary laid out as such:</p>
  
  <pre><code>legJointConnectors = {'L_hip_jnt': ['L_knee_jnt'], 'L_knee_jnt': ['L_ankle_jnt'], 'L_ankle_jnt': ['L_ball_jnt'], 'L_ball_jnt': ['L_toe_jnt']}
  </code></pre>
  
  <p>What I want to be able to do is iterate through this, but change the L_ to R_. Here's how I tried to do it, but it failed, because it's expecting a string and I'm passing it a list.</p>
  
  <pre><code>for key, value in legJointConnectors.iteritems():
      if side == 'L':
          cmds.connectJoint(value, key, pm=True)
      else:
          key = re.sub('L_', 'R_', key)
          value = re.sub('L_', 'R_', value)
          cmds.connectJoint(value, key, pm=True)
  </code></pre>
  
  <p>Obviously I'm not doing this correctly, so how can I do this? Should I create an empty dictionary and populate it with the necessary data on the fly? Or is there a better way to do it? Thanks for the help!</p>
  
  <p>[edit] The if side == 'L' is testing to see what side we're currently working on. This script is being used within Maya, so I'm creating joints based on the side and then connecting them.</p>
  
  <p>Based off of KennyTM's suggestion I tried this:</p>
  
  <pre><code>for key, value in legJointConnectors.iteritems():
          if side == 'L':
              cmds.connectJoint(value, key, pm=True)
          else:
              for v in value:
                  value = 'R_' + v[2:]
                  for k in key:    
                      key = 'R_' + k[2:]
                  print key
              print value
  </code></pre>
  
  <p>but while it returns the correct key, the value returns as R_</p>