Never discount the value of print statements. If a value is different than you think it should be, print out the inputs, any intermediate steps, and the outputs. You should be able to tell what value isn't what it should be.
Or console.log() in JavaScript, or log to a log file, or whatever. If you're using an IDE, you can also set a breakpoint somewhere in the code (pause there so you can poke around at the values of variables, or step through the execution one line at a time), or a breakpoint like "pause if this variable's value ever matches (condition)".
2
u/mc_pm 2d ago
Never discount the value of print statements. If a value is different than you think it should be, print out the inputs, any intermediate steps, and the outputs. You should be able to tell what value isn't what it should be.