'''
Fruits_by_color = {'Yellow':{'Banana', 'Pineapple', 'Passion_Fruit'}, 'Green':{'Avocado', 'Lime', 'Water_melon'}, 'Red':{'Strawberries', 'Apples', 'RaspBerries', 'Pomegranate'}}
def Fruit_color(fruit, dict_):
for color, fruit in dict_.items():
color = dict_[color]
fruit = dict_[color][fruit]
try:
print('The color of', fruit, 'is', color)
except:
print('There is no such fruit in our data base.')
Fruit_color('Banana', Fruits_by_color)
'''
TypeError: unhashable type: 'set'
I've also tried using a list of dictionaries instead of a nested dictionary, but then i've got syntax error:
'''
Fruits_by_color = ['Yellow':{'Banana', 'Pineapple', 'Passion_Fruit'}, 'Green':{'Avocado', 'Lime', 'Water_melon'}, 'Red':{'Strawberries', 'Apples', 'RaspBerries', 'Pomegranate'}]
def Fruit_color(fruit, list_):
for color, fruit in list_():
color = list_[color]
fruit = list_[color][fruit]
try:
print('The color of', fruit, 'is', color)
except:
print('There is no such fruit in our data base.')
Fruit_color('Banana', Fruits_by_color)
'''
I then get a SyntaxError