What you need
- Exercise code you are working on
- Text editor or IDE
- Access to interpreter/compiler
- Paper/notes for tracking steps
Every step
- 1
Reproduce and record the exact error
Run the smallest version that still fails and copy the full error message. In Python, print("Result: ", sum([1,2,3]) is missing the final closing parenthesis. The exact syntax-error wording depends on the Python version. Record the input and the expected result, not just “it does not work.”
CHECKPOINT · You can reproduce the failure with one small example. - 2
Read the error with its surrounding code
Look at the reported line and the lines just before it. A parser may notice a missing bracket only after reaching a later line or the end of the file. In the sample, the list closes with ], the sum call closes with ), and the outer print call still needs its own closing parenthesis.
CHECKPOINT · You can identify which opening delimiter lacks a matching close. - 3
Check for typos or simple omissions
Compare the error line with expected syntax. For 'print("Result: ", sum([1,2,3)' correct to 'print("Result: ", sum([1,2,3]))'. Rerun the program to see if the error is resolved.
CHECKPOINT · Typo corrected and code runs without that error - 4
Inspect values when the code runs but behaves incorrectly
For a calculation bug, print the inputs and intermediate results. The sum of [1, 2, 3] should be 6. If your requirement was to sum only the first two entries, the expected result is 3 and the input selection needs changing. Work from the written requirement instead of changing correct arithmetic to fit a guess.
CHECKPOINT · You know which intermediate value first differs from the intended behavior. - 5
Test edge cases or alternative inputs
Try changing input values to see if errors persist. For example, replace [1,2,3] with [0,-1,1] in the sum to check code flexibility. This reveals if logic errors are hidden by original test cases.
CHECKPOINT · Code behaves correctly with different inputs
Common mistakes
- Don't trust your eyes—typos can be hard to spot without carefully reading each character.
- Changing code to 'fix' issues without testing can introduce new errors.
Finished when
Code runs without errors and produces correct output for multiple test cases.
Questions about this task
What if there’s no error message but the code is wrong?
Use print statements or a debugger to check what your variables hold at each step. Walk through the code logic until you spot the mistake.
How can I find missing or extra punctuation?
Compare your code to the example in the textbook or assignment description, character by character. Pay close attention to parentheses, colons, and quotes.
Make these steps fit your situation.
Ask a question about this task or prepare a draft you can review.
Work through it with meHelp me make it