Ask coding questions

← Back to all posts
List Index Out Of Range
Brendan23

First, I know what the list index out of range error is. To see this error, run the repl, do check orders, then go to make food and make one of the foods that had a 1 or more next to it when you checked check orders, then go to serve food and press ENTER, you should get the error.

Answered by Kai_Justice [earned 5 cycles]
View Answer
Voters
Brendan23
Comments
hotnewtop
Kai_Justice

I suggest just enumerating the list, it'll make your code a bit cleaner and clear up any index related confusion.
Lines 130-137:

I kept the indentation in case you want to copy and paste it.

Brendan23

@Kai_Justice hmmm, ok, I'll try i.

Brendan23

@Kai_Justice hmmm...

Kai_Justice

@Brendan23
Line 131 is redundant because the variable "thing" is taken directly from the list. Should be changed to: if thing in done_things:

Brendan23

@Kai_Justice great, thanks!

InvisibleOne

Well, done_things is not a list, it's a dictionary.

Brendan23

@InvisibleOne why does it give a 'List index out of range` error then?