[Tutor] deleting elements of a dictionary

Peter Otten __peter__ at web.de
Fri May 19 05:11:29 EDT 2017

Michael C wrote:

>   for n in list(read_dictionary):
>>     print(read_dictionary[n])
>>     if read_dictionary[n] == '5':
>>         del read_dictionary[n]
> After doing this how do I save it back to the dictionary?
> then i ll do this
> numpy.save('loc_string_dictionary.npy', dictionary)

Hm, the dict is called `read_dictionary`, so you save it with

numpy.save('loc_string_dictionary.npy', read_dictionary)

but I may have understood the question.
If so, please clarify.

More information about the Tutor mailing list