Я делаю приложение для планирования питания, которое позволяет вам устанавливать ингредиенты, которые у вас есть, и рецепты, и дает вам список покупок на их основе. Однако, когда я запускаю его, я получаю следующие ошибки:
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"
Я просмотрел этот вопрос, но он не отвечает на мой вопрос: Python - IndexError: индекс списка вне диапазон
Вот мой код:
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)