Debugging strategies

Read the error

Start at the last line of the traceback — the exception type and message. Then find your file and line number.

Print debugging

print("DEBUG:", variable)

Binary search the bug

Comment out half the code. If the error disappears, the bug is in the part you removed. Repeat.

Rubber duck method

Explain the code out loud line by line — often you spot the mistake yourself.

Reflect

Quick check

Use these strategies the next time your program breaks.

0% complete
Check when done