Jul-11-2022, 08:31 PM
Hi! I try to modify the function below with list comprehation.
But I don't now how to write that else secvantion
This:
But I don't now how to write that else secvantion
This:
def cakes(recipe, available):
list_value = [ ]
for key,value in recipe.items():
if key in available:
a = int(available[key]) // int(value)
list_value.append(a)
else:
return 0
list_value.sort()
return list_value[0] In this:def cakes(recipe, available):
list_value = [int(available[key]) // int(value) for key,value in recipe.items() if key in available else return 0 ].sort()
return list_value[0]
