I need to write a function that takes three dishes and a specified ingredient and outputs true if all the dishes are free from that ingredient and false if ANY of them contain it. The inputs are the menu which is three lists of strings and the specified ingredient. I thought I had done it correctly until i went to test and got a failure. I cannot understand why?
I defined my function follows -
def free_from(test_menu:str, specified_ingredient: str):
if specified_ingredient in test_menu:
return(False)
else:
return(True)
The test that failed is as follows
test_menu = [ ['soup'],
['cheese'],
['water'] ]
expected_result = False
if free_from(test_menu, 'water') == expected_result:
#adjust the function call if necessary to match your implementation
print('Working')
else:
print('Failure')
The output i get is 'Failure'