Created
June 30, 2019 06:33
-
-
Save melvinkcx/c42d402bb8d510ad80e002478a6e8131 to your computer and use it in GitHub Desktop.
Filtering Dictionary In Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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