I have a nested dictionary that I would like to split based on the value of end qty. I would like to only keep keys in which 'end qty' == 0. I believe it can be done easily with dictionary comprehension, but I can't quite get it right.
import datetime d = { 'ID1' : {'start qty': 13 , 'end qty': 40}, 'ID2' : {'start qty': 10 , 'end qty': 0}, 'UD3' : {'start qty': 30 , 'end qty': 30}, 'ID4' : {'start qty': 20 , 'end qty': 0}, } print { k:v for k, v in d.items() if ['end qty'] == 0 }
if v['end qty'] == 0?