Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Filtering Dictionary In Python 3
"""
Solution #2: Create a copy of keys
"""
coffees = get_menu()
key_copy = tuple(coffees.keys()) # Feel free to use any iterable collection
for k in key_copy:
if coffees[k].get("sugar_free") is True:
del coffees[k]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.