title: Remove "First" Item From Python Dict
body: <p>Good afternoon.</p>
  <p>I'm sorry if my question may seem dumb or if it has already been posted (I looked for it but didn't seem to find anything. If I'm wrong, please let me know: I'm new here and I may not be the best at searching for the correct questions).</p>
  <p>I was wondering if it was possible to remove (pop) a generic item from a dictionary in python.
  The idea came from the following exercise:</p>
  <blockquote>
  <p>Write a function to find the sum of the VALUES in a given dictionary.</p>
  </blockquote>
  <p>Obviously there are many ways to do it: summing <code>dictionary.values()</code>, creating a variable for the sum and iterate through the dict and updating it, etc.. But I was trying to solve it with recursion, with something like:</p>
  <pre><code>def total_sum(dictionary):
      if dictionary == {}:
          return 0 
      return dictionary.pop() + total_sum(dictionary) 
  </code></pre>
  <p>The problem with this idea is that we don't know <em>a priori</em> which could be the &quot;first&quot; key of a dict since it's unordered: if it was a list, the index 0 would have been used and it all would have worked.
  Since I don't care about the order in which the items are popped, it would be enough to have a way to delete any of the items (a &quot;generic&quot; item). Do you think something like this is possible or should I necessarily make use of some auxiliary variable, losing the whole point of the use of recursion, whose advantage would be a very concise and simple code?</p>
  <p>I actually found the following solution, which though, as you can see, makes the code more complex and harder to read: I reckon it could still be interesting and useful if there was some built-in, simple and direct solution to that particular problem of removing the &quot;first&quot; item of a dict, although many &quot;artificious&quot;, alternative solutions could be found.</p>
  <pre><code>def total_sum(dictionary):
      if dictionary == {}:
          return 0
      return dictionary.pop(list(dictionary.keys())[0]) + total_sum(dictionary)
  </code></pre>
  <p>I will let you here a simple example dictionary on which the function could be applied, if you want to make some simple tests.</p>
  <pre><code>ex_dict = {&quot;milk&quot;:5, &quot;eggs&quot;:2, &quot;flour&quot;: 3}
  </code></pre>