CodeLab Solution 51302




CS101 CodeLab Solutions

CodeLab Solution 51302

Given a dictionary d and a list lst, remove all elements from the dictionary whose key is an element of lst. For example, given the dictionary {1:2, 3:4, 5:6, 7:8} and the list [1, 7], the resulting dictionary would be {3:4, 5:6}. Assume every element of the list is a key in the dictionary.

[cc lang=”PYTHON”] for i in lst:
del(d[i])
[/cc]


No Comments Yet.

Leave a comment

You must be Logged in to post a comment.