PeteCake 字典和最小值

def cakes(recipe, available):
# TODO: insert code
count = []
for item in recipe:
if item not in available:
return 0
else:
count.append(int(available[item]/recipe[item]))
return min(count)

还可以

def cakes(recipe, available): return min(available.get(k, 0)/recipe[k] for k in recipe)

原文地址:https://www.cnblogs.com/sayHello2World/p/7131103.html