Is it legitimate to delete items from a dictionary in Python while iterating over it?
For example:
for k, v in mydict.iteritems(): if k == val:
Iterate over a copy instead, such as the one returned by items():
items()
for k, v in list(mydict.items()):