Record a repeatable failure
Save the command, exact input, expected output, and actual output. If a ten-record input fails, try shortening it while keeping the failure. That gives you a smaller example to inspect and share.
Find the first useful line in the stack trace
For a Python traceback, start with the exception name at the bottom, then locate the failing line in your code. In Java, look for the exception or underlying cause and the nearby stack frames that reference your own classes. Inspect the variables used on that line.
Check your assumptions with one observation
If Python raises IndexError, compare the index with the list length immediately before the access. For a Java NullPointerException, identify which reference is null and trace where that value came from. Use a breakpoint or a temporary print to confirm your hypothesis.
Test the fix and one neighboring case
Re-run the smallest example that failed. Then try a case that previously worked and a boundary case. For an off-by-one error, an empty list, a one-item list, and a two-item list are a useful starting set.