def in_fridge(): try: count=fridge[wangted_food] except KeyError: count=0 return count fridge={'apples':10,'oranges':3,'milk':2} wangted_food='apples' in_fridge()
相关分类