title: Replacing keys in dictionary conditional on its value
body: <p>I am trying to remove the last character of keys in dictionary if its value is 1:</p>
  
  <pre><code>d = {'hours': 1, 'seconds': 30}
  
  for k,v in d.items():
        if v == 1:
          print(k)
          d[k[:-1]] = d.pop(k)
  </code></pre>
  
  <p>However, it keeps popping until the key is left with 1 character. hours in this case becomes h when it should become hour.</p>