fruit_colours = { "Red": ("Apple", "Raspberry", "Strawberry"), "Orange": ("Orange",), "Yellow": ("Banana", "Lemon", "Pineapple"), "Green": ("Avocado", "Lime", "Melon", "Pear"), "Blue": ("Blueberry", "Huckleberry"), "Purple": ("Plum", "Grape", "Maquiberry") } def colour_of_fruit(fruit: str) -> str: """Returns the color of given fruit.""" for color, fruits in fruit_colours.items(): if fruit in fruits: return color return "Not a fruit!"
- fruit_colours = {
"Apple" : "Red","Raspberry" : "Red","Strawberry" : "Red","Orange" : "Orange","Banana" : "Yellow","Lemon" : "Yellow","Pineapple" : "Yellow","Avocado" : "Green","Lime" : "Green","Melon" : "Green","Pear" : "Green","Blueberry" : "Blue","Huckleberry" : "Blue","Plum" : "Purple","Grape" : "Purple","Maquiberry" : "Purple"- "Red": ("Apple", "Raspberry", "Strawberry"),
- "Orange": ("Orange",),
- "Yellow": ("Banana", "Lemon", "Pineapple"),
- "Green": ("Avocado", "Lime", "Melon", "Pear"),
- "Blue": ("Blueberry", "Huckleberry"),
- "Purple": ("Plum", "Grape", "Maquiberry")
- }
- def colour_of_fruit(fruit: str) -> str:
- """Returns the color of given fruit."""
return fruit_colours.get(fruit, "Not a fruit!")- for color, fruits in fruit_colours.items():
- if fruit in fruits: return color
- return "Not a fruit!"