Goal: Have a dictionary-comprehension that removes a given key, if its respective value is "empty".
Empty means anything such as: [], 0, None, 0.0, "" etc.
Code:
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": '' # [], 0, None, 0.0, "" etc.
}
print(thisdict)
thisdict = {val for key, val in thisdict.items() if val} # Attempt
Please let me know if there is anything else I can add to post to help further clarify.