title: Python RuntimeError: dictionary changed size during iteration
body: <p>I am practising a really easy python code. I have tried to find the solution of it, but couldn't find it. </p>
  
  <pre><code>def del_contacts():
  for name, number in d1.items():
      if (del_name == name):
          del d1.name and print ("Contact deleted!")
  else:
      print ("Contact does not exist")
  
  z = input ("Do you wish to delete any of the number you added? ")
  if z == 'yes':
      del_name = input ("Type the name of the contact you wish to delete")
      del_contacts()
  else:
      print ("ok")
  </code></pre>
  
  <p>but this gives me error <code>in &lt;module&gt; del_contacts()</code> 
  followed with 
  <code>in del_contacts for name, numbers in d1.items(): RuntimeError: dictionary changed size during iteration</code></p>
  
  <p>Have been facing such problem a lot. Can anyone please tell me WHY this error is happening? Any fix and what should I do in future to avoid such errors?</p>