I am trying to make a weekly meal prep program in Python. Part of that program is having a database of recipes that the user has entered. I thought the best way to make this would be to make a class Recipe where it stores the title, ingredients (as a dictionary with the key being the ingredient and the amount being value) and then the instructions. However I can't find a way to make a new variable each time I try to input a new recipe.
This is my class code
class Recipe:
def __init__(self):
ingredients = {}
while True:
ingredient = input('Type in an ingredient. Type finish when you have added in all the ingredients. ')
if ingredient == 'finish':
break
amount = input("How much of this ingredient? ")
ingredients[ingredient]=amount
self.ingredients = ingredients
self.title = input('What is the name of the recipe? ')
self.instructions = input('Type out your recipe instructions; ')
meal1 = Recipe()
print(meal1.title)
print(meal1.ingredients)
print(meal1.instructions)
Basically this works for creating one recipe. But instead of the ''' meal1 = Recipe()''' I want to create a new recipe each time the user selects the option in the main menu to 'add a recipe' how can I accomplish this without making lots of pre-named variables.