Ask coding questions

← Back to all posts
List Index Out Of Range
Brendan23 (166)

If You Run The Repl, do make food, wait 20 sec., and serve food, it will give a list index out of range error, why is that?

Comments
hotnewtop
ruiwenge2 (623)

that is because the number you used to get an element in the list is out of range, meaning there is no element with that index.

Brendan23 (166)

@ruiwenge2 I know, but I can't find why that happens in my code, I have a list and things in that list, is it just a off by one mistake?

ruiwenge2 (623)

@Brendan23 in line 133 you spelled done_things incorrectly, maybe fix that if it is causing the problem

Brendan23 (166)

@ruiwenge2 no, it's supposed to be like that, there is a seperate dict called done_thingss

ruiwenge2 (623)

@Brendan23 for some reason I don’t get the error though

Brendan23 (166)

@ruiwenge2 you have to make sure that the food you pick is one of the ones in the "Check Orders" thing

ruiwenge2 (623)

@Brendan23 when I pick the food it just shows press enter to serve food or e to exit

Brendan23 (166)

@ruiwenge2 right, you will have to press enter. then you should get the error

ruiwenge2 (623)

@Brendan23 the thing is, the error does't happen to me... can you send a screenshot?

Brendan23 (166)

@ruiwenge2 alright. hold on a sec.

ruiwenge2 (623)

@Brendan23 hmmm... maybe the done_things list doesn't have that index number?

Brendan23 (166)

@ruiwenge2 can you test it again, I changed it so you should get an error this time.

ruiwenge2 (623)

@Brendan23 but why did you change it so i WOULD get an error?

lol

but i still don't see an error. thats good!

Brendan23 (166)

@ruiwenge2 Let me give you instructions, go to check orders/input 1, then go to make food and make a food that had 1 or more next to it when you did check orders. then input 2/serve food and press enter. make sure the food is one that had1 or more next to it when you looked at check orders.

ruiwenge2 (623)

@Brendan23 oh i get the error now.