title: How to to change the keys in a dictionary?
body: <p>I have a dictionary of dog owners and i need to write a function <code>update_age()</code> that will update the dogs owner's ages in the dictionary. Here is an example:</p>
  <pre><code>dog_owners = {(&quot;John&quot;, &quot;Malkovic&quot;, 22): [&quot;Fido&quot;],
                (&quot;Jake&quot;, &quot;Smirnoff&quot;, 18): [&quot;Butch&quot;],
                (&quot;Simon&quot;, &quot;Ng&quot;, 32): [&quot;Zooma&quot;, &quot;Rocky&quot;],
                (&quot;Martha&quot;, &quot;Black&quot;, 73): [&quot;Chase&quot;]}
  </code></pre>
  <p>So the key is a tuple in which the numbers 22, 18, 32, and 73 represent age.
  The function <code>update_age()</code> has 3 arguments: name of dictionary, tuple with 3 elements, the number that should change the number from the tuple.</p>
  <p>Example:</p>
  <pre><code>update_age(dog_owners, (&quot;Jake&quot;, &quot;Smirnoff&quot;, 18), 22)
  dog_owners[(&quot;Jake&quot;, &quot;Smirnoff&quot;, 22)] == ['Butch']
  dog_owners.get((&quot;Jake&quot;, &quot;Smirnoff&quot;, 18)) is None
  </code></pre>
  <p>I tried to do:</p>
  <pre><code>def update_age(owners, owner, new_age):
      b = (new_age,)
      return owner[0:2] + b
  </code></pre>
  <p>but it is not correct because the original key still has the previous value and if i write:</p>
  <pre><code>print(update_age(dog_owners, (&quot;Jake&quot;, &quot;Smirnoff&quot;, 18), 22))   # for check
  print(dog_owners.get((&quot;Jake&quot;, &quot;Smirnoff&quot;, 18)) is None)
  </code></pre>
  <p>the answer will be</p>
  <pre class="lang-none prettyprint-override"><code>('Jake', 'Smirnoff', 22)
  False
  </code></pre>
  <p>So it means that my original key still has its previous value. How can I change it? May be I should try <code>pop()</code> and than add a new tuple to the key, but I don't know how.</p>