Skip to content

Instantly share code, notes, and snippets.

@raeq
Created May 8, 2020 08:05
Show Gist options
  • Save raeq/e1314c0f7fe35f68e7b2328b9aecd697 to your computer and use it in GitHub Desktop.
Save raeq/e1314c0f7fe35f68e7b2328b9aecd697 to your computer and use it in GitHub Desktop.
fruits_dict: dict = dict()
citrusfruit: set = {"oranges", "lemons", "limes", "satsumas", "nectarines"}
treefruit: set = {"apples", "pears", "cherries", "plums", "peaches", "plums",
"cherries", "oranges", "lemons", "limes"}
stonefruit: set = {"cherries", "plums", "peaches", "nectarines"}
for fruit in citrusfruit.union(stonefruit).union(treefruit):
fruits_dict.setdefault(fruit, [])
for key, value in fruits_dict.items():
if key in citrusfruit:
value.append("citrusfruit")
if key in treefruit:
value.append("treefruit")
if key in stonefruit:
value.append("stonefruit")
print(fruits_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment