title: "Remove" in else clause changes results of loop over json dict
body: <p>I am iterating over a dict created from a json file which works fine but as soon as I remove some of the entries in the <code>else</code> clause the results change (normally it prints 35 nuts_ids but with the <code>remove</code> in the <code>else</code> only 32 are printed. So it seems that the remove influences the iterating but why? The key should be safe? How can I do this appropriately without loosing data?</p>
  
  <pre><code>import json
  
  with open("test.json") as json_file:
      json_data = json.load(json_file)
  
  for g in json_data["features"]:
      poly = g["geometry"]
      cntr_code = g["properties"]["CNTR_CODE"]
      nuts_id = g["properties"]["NUTS_ID"]
      name = g["properties"]["NUTS_NAME"]
      if cntr_code == "AT":
          print(nuts_id)
          # do plotting etc
      else: # delete it if it is not part a specific country
          json_data["features"].remove(g)  # line in question
  
  # do something else with the json_data
  </code></pre>