So I have a dictionary filled with lots of useful stuff. I would like to remove a key (build a new dict without the key) if any value within a list is empty.
The dictionary:
>>>print(vaar123)
{'moo': 'cora', 'ham': ['', 'test'], 'bye': 2, 'pigeon': '', 'heloo': 1}
I can remove the 'pigeon' key with its empty value with something along the lines of.
>>>dict((k, v) for k, v in vaar123.items() if v)
{'moo': 'cora', 'ham': ['', 'test'], 'heloo': 1, 'bye': 2}
But try as I might, I cannot seem to come up with a method to remove 'ham' as it has an empty value in its list.
Thanks in advance for any suggestions, Frank
Info: The dictionary is built with a value on creation (set by admin) the additional value is added to the list by user input. The value pair is used as output. Having a single value in the list produces undesirable output.
This function recursively checks
Sized
Iterable
s to see if they are empty and returns False if it finds one that isThen we can use this to winnow the dict
outputs: