I am making a meal planning application that allows you to set ingredients you have and recipes and gives you a grocery list based on it. When I run it, however, I get these errors:
IndexError: list index out of range
Exception in Tkinter callback
...
Line 15: recipes[row-1].append(recipeIngredient): IndexError: list index out of range
File "/Users/*****/Documents/shopping planner.py"
I have looked at this question, but it doesn't answer my question:
Python - IndexError: list index out of range
Here's my code:
def MkRecipe():
recipe_creator = tkinter.Button(window, text=" ", command=MkIngredient(len(recipes)))
recipe_creator.grid(row=1, column=(len(recipes)+1))
recipes.append([])
def mkIngredient(row):
recipeIngredient = tkinter.Entry()
recipes[row-1].append(recipeIngredient)
recipeIngredient.grid(row=len(recipes[row]), column=row)