What would be the most efficient way to get all dict items with value == 3
and create a new dict?
Here is what I have thus far:
d = {1: 2, 2: 2, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, ...}
new_d = {}
for item in d:
if d[item] == 3:
new_d[item] = d[item]
Is there a more efficient, simpler way to do this? Perhaps using a map?