Let’s go over some debugging tips you might find useful.
If you have some code that isn’t quite doing what you think it should, the first thing to do is to try is using copious amounts of info statements.
In this example, we might want to put the iteration count.
If we run the code, we can see it’ll run through.
It might discover that something wasn’t working the way that we thought it should.
From there, we might comment out some code to see whether that changes the behavior and help us nail down what isn’t working how we wanted it to.
That combination of commenting things out and using info statements is generally the best way to be able to debug and figure out what’s going wrong.