Ask coding questions

← Back to all posts
For Loop Not Working
Brendan23 (166)

If you run the repl, make 2 or more food, then do serve food, it will only do one of them. why is that, and how do I solve it?

Comments
hotnewtop
IMayBeMe (529)

It seems to work fine for me?

Brendan23 (166)

@IMayBeMe hmmm, let me explain it more carefully, go to check orders, then go to make food and make 2 or more foods that had a one or more next to it when you checked orders. then go to serve food and it should only show 1 correct order not 2, which is how many it should show. Also, I added print('loop') to show how many times it loops, (in this case, it should be 2 times.)

[deleted]

@Brendan23 Hi, um, I'm not sure, but is loop a variable? I went into your code and as noted above, you said print('loop'), because if loop is a variable, then it should be print(loop) so it prints the variable loop instead of the string "loop".

Brendan23 (166)

@Aphmeta No, I just print "loop" to show how many times it loops.

[deleted]

@Brendan23 Ok, gotcha. I also have a question on your repl, whenever I type something, like "make food" or "Make food", it says invalid input. Is it because I have zero money? If so, I would recommend that you give everyone money at the beginning and list the price to do something, and maybe have a "help" function.

Brendan23 (166)

@Aphmeta You type in the number next to that option, for example: "make food" would make you input "3". me It's not finished yet, I will add those features later.

[deleted]

@Brendan23 Gotcha