I have a python dictionary. Just to give out context, I am trying to write my own simple cross validation unit.
So basically what I want is to get all the values exc
Given a dictionary say
d = {
2: 2, 5: 16, 6: 5,
7: 6, 11: 17, 12: 9,
15: 18, 16: 1, 18: 16,
19: 17, 20: 10
}
then the simple comprehension example would attain what you possibly desire
[v for k,v in d.iteritems() if k not in (2,5)]
This example lists all values not with keys {2,5}
for example the O/P of the above comprehension is
[5, 6, 1, 17, 9, 18, 1, 16, 17, 10]