You can add a conditional breakpoint on the last line and set the condition to be something that occurs only in the last iteration.
In this instance the condition is very easy since it’s just i == 9
, but it may be a lot more complex depending on your loop condition so sometimes adding a statement at the end will be the easier solution.
That screenshot is from IntelliJ IDEA and your screenshot looks like it’s from the same IDE, so just right-click the breakpoint to show the dialog and enter your condition.
If you’re using some other IDE I’m sure there is capability to make a breakpoint conditional.
Update:
There is no support for breaking at the end of a method in the Python debugger, only at the start of a method:
b(reak) [[filename:]lineno | function[, condition]]
With a lineno argument, set a break there in the current file. With a function argument, set a break at the first executable statement within that function. The line number may be prefixed with a filename and a colon, to specify a breakpoint in another file (probably one that hasn’t been loaded yet). The file is searched on sys.path. Note that each breakpoint is assigned a number to which all the other breakpoint commands refer.
If a second argument is present, it is an expression which must evaluate to true before the breakpoint is honored.
Without argument, list all breaks, including for each breakpoint, the number of times that breakpoint has been hit, the current ignore count, and the associated condition if any.