Kaloyankerr

make chocolade

Dec 12th, 2020
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. Първо решение:
  2.     def make_chocolate(self, recipe_name: str):
  3.         if recipe_name not in self.recipes:
  4.             raise TypeError("No such recipe")
  5.         else:
  6.             for ingredient in self.recipes[recipe_name]:
  7.                 ingredient_quantity = self.recipes[recipe_name][ingredient]
  8.                 self.remove_ingredient(ingredient_type=ingredient, quantity=ingredient_quantity)
  9.  
  10.             if recipe_name not in self.products:
  11.                 self.products[recipe_name] = 0
  12.             self.products[recipe_name] += 1
  13.  
  14. Второ решение:
  15. def make_chocolate(self, recipe_name: str):
  16.     if recipe_name not in self.recipes:
  17.         raise TypeError("No such recipe")
  18.     else:
  19.         for ingredient_type, quantity in self.recipes[recipe_name].items():
  20.             self.remove_ingredient(ingredient_type, quantity)
  21.         self.products[recipe_name] += 1
Advertisement
Add Comment
Please, Sign In to add comment