print and breakpoint — finding the bad value before AI does — step 9 of 9
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Final drill. The function safe_divide has a subtle bug — when b
is 0 it returns None instead of the string "undefined". Add
print-tracing and fix the bug so the output is exactly:
trace: a=10, b=2
5.0
trace: a=10, b=0
undefined
The trace: line goes at the start of the function on each call.
The bug fix goes inside the function body.
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Final drill. The function safe_divide has a subtle bug — when b
is 0 it returns None instead of the string "undefined". Add
print-tracing and fix the bug so the output is exactly:
trace: a=10, b=2
5.0
trace: a=10, b=0
undefined
The trace: line goes at the start of the function on each call.
The bug fix goes inside the function body.
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.