One of the most dangerous bugs isn't a SyntaxError.
It isn't an exception.
It doesn't even produce a traceback.
Sometimes Python executes your entire program successfully...
…and gives you the wrong answer.
Consider this:
def calcular_total(precios, descuento):
subtotal = sum(precios)
total = subtotal - descuento
return total
precios = [120000, 80000]
descuento = 0.10
print(calcular_total(precios, descuento))
Expected:
180000
Actual:
199999.9
Python isn't broken.
Our assumption is.
And that's where debugging becomes much more interesting.
A mistake I made when learning to debug was asking:
“What should I print?”
A better question is:
“What do I need to observe to prove or reject my hypothesis?”
That changes debugging from guessing into an experiment:
Reproduce → Hypothesis → Measure → Evidence → Conclusion
For example:
Are the inputs correct?
Is subtotal correct?
Is descuento what we expect?
At which exact operation does the state become wrong?
Once you know that:
subtotal = 200000 ✓
descuento = 0.10 ✓
the search space becomes tiny.
The suspicious operation is now:
subtotal - descuento
That's the real goal of debugging:
Turn “something is wrong” into one small, testable question.
I wrote a practical guide showing this process with print(), type(), repr(), breakpoint() and step-by-step state inspection.
Top comments (0)