I have a question regarding a dictionary in python and empty values. If I had the following dictionary
my_dict={'a':[],
'b':[1],
'c':[],
'd':[]
}
How I could remove empty values [] and appending the keys in an empty list?
my_dict={
'b':[1],
}
and empty_list=['a','c','d']
.
With a list I would do as follows (but there are several ways to do the same):
my_dict = list(filter(None, my_dict))
But I have realised I do not know how to do the same in a dictionary.