Stick to one plan.
Make your code do that
Back to the prints though, there are things in that code that don’t add up at all, if you print out what’s being done you’ll find that things aren’t what you mean for them to be, and then you can reconsider what you meant, and where that information exist, adjust it, and continue from there.
You may even find things by reading the code, and considering what was said earlier. But that’s harder, and not really any advantage over simply looking at what happens as it runs.
If you look at someone cook and they put in too many eggs, you can tell. But only if you’re looking. (and know what’s supposed to happen, ie having a plan)
Also, that plan better make sense. You should for example be able to carry it out on paper and get the correct result. If it turns out the plan doesn’t actually add up and you rely on human auto correction of the “that’s what I meant” type, then, there isn’t really a plan after all, implementing a plan like that is going to result in a program that doesn’t add up, and it certainly won’t do the right thing even if you meant it, it’ll do what you wrote.
Regarding making that plan, keep in mind that this is a task that you know how to carry out manually. So you already have a plan by virtue of being a human, you just need to consider what you the human would do, your program should probably not be doing it any differently.