#Help me understand why this loop is not working?
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
To help you understand why the loop is not working, please provide the code snippet that you are referring to.
It depends on the context and requirements of the situation. If you are asked to send or share code, it is common to send it in text form. This can be done by copying and pasting the code into a text file or using a code-sharing platform or service. However, if you are working with a specific development environment or tool, there may be other methods for sharing code, such as sending project files or using version control systems.
There could be several reasons why a for loop is not incrementing:
-
Incorrect initialization: The loop may not be initialized properly, resulting in the loop variable not being set to the desired starting value.
-
Incorrect condition: The condition of the loop may not be set correctly, causing the loop to terminate prematurely or not execute at all.
-
Missing or incorrect increment statement: The increment statement within the loop may be missing or written incorrectly, preventing the loop variable from being incremented.
-
Infinite loop: If there is an error in the loop logic, it is possible that the loop is stuck in an infinite loop, where it keeps executing without ever reaching the termination condition.
-
External interference: There might be external factors affecting the execution of the for loop, such as other code modifying variables used in the loop or unexpected input causing unintended behavior.
-
Syntax errors: Syntax errors in the for loop declaration or any other part of the code can prevent proper execution and result in no incrementation.
-
Loop variable modification within the loop: If there are statements within the for loop that modify the value of the loop variable directly, it can interfere with its expected incrementation.
To identify and resolve these issues, it is important to carefully review and debug your code, checking each component of the for loop and ensuring that it functions as intended.
what is not working exactly
and why do you think that?
because my code prints out every increment and it doesn't print out 9, and i did something like if i=9, print out "hi" and it didn't print out hi
can you show your class implementation used in the scores array pls
what is that ;-;
yeah
it's a superclass for scores
no
first did you try adding a print at the front of your for loop
to see if its actually running/failing
yeah
An infinite loop is not the outcome... There is no other modification of i other than the for loop.
Does it maybe hang in the Calculate method for the entry in scores[9]?
You need to do as SquidXTV suggests and find out where in the loop it is getting stuck.
okay noted
alright
i'm just going to look over the (9) subclass and fix it before i come back
thank you guys 🥺
you might be stuck in else if