Add print statements in your code to follow what it ends up doing. Compare to what it should be doing.
You should also know what difference that makes to your code, or if not, then you’ve got something that you urgently need to figure out before moving ahead. (Can’t really write anything by guessing what does what, and you especially can’t fix something that you don’t understand the individual components of)
Very few things snap into place by simply having a small amount of possible configurations that can be shuffled around. One needs to put things where they belong.
You’re right to stop and think about this, but there’s one more step to take before asking, which is considering why you can’t answer that yourself, and you’ll find that the answer to that is that you haven’t fully figured out what the things you were changing, do. (if-statements, for-loops, return statements), and that tells you that there is something you can look at in order to answer your own question