[Tutor] deleting elements of a dictionary
mysecretrobotfactory at gmail.com
Thu May 18 12:55:12 EDT 2017
I am trying to remove incorrect entries of my dictionary.
I have multiple keys for the same value,
and I have found out that some key:value pairs are incorrect, and the best
thing to do
is to delete all entries who value is 5. So this is what I am doing:
read_dictionary = numpy.load('loc_string_dictionary.npy').item()
for n in read_dictionary:
if read_dictionary[n] == '5':
However, I get this error:
RuntimeError: dictionary changed size during iteration
and I can see why.
What's the better thing to do?
More information about the Tutor