🧩Debugging
Also known as Debug
The work of finding out why code goes wrong, then fixing it.
Think of it like
Think of it like being a detective. You gather clues, guess who did it, and test your guess.
Example
Lucy's total is off by one cent. She prints the value after each step and finds a float rounding error on line 14.
Why it matters
Every developer spends a large share of their time debugging. Doing it with a method saves hours.
Definition
Example code
python
total = 0
for price in [0.1, 0.2]:
total = total + price
print("total so far:", total) # a quick debug lineCommon mistake
Key takeaways
- 1Make it happen again. A bug you can repeat is half fixed.
- 2Narrow it down. Cut the search area in half each step.
- 3Check the fix. Run the failing case again after.