[Tutor] deleting elements of a dictionary

Alan Gauld alan.gauld at yahoo.co.uk
Fri May 19 13:17:03 EDT 2017

On 19/05/17 15:23, Michael C wrote:
> list(read_dictionary) converts the dictionary into a list right? How can
> you save the list as a dictionary?

Nope, list() produces a new list object containing the
keys of the dictionary. In the old day(of python 2) you
used to get the same effect using

for key in mydict.keys()

but keys() now returns a funky view of the original dict
keys and I suspect you'd have the same problems when
deleting items. So Peter's list() is probably the best

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list