Sometimes my print statements don't work

I’ve added print statements in the user code section of assignments before to help debug. Now (week 4) my print statements don’t return anything when I call the test. It’s as if I didn’t enter them at all.

Any guidance on this? Is there some switch suppressing output that I need to change? I don’t want to copy all the data sets and tests to my laptop just to be able to debug.


I closed the browser tab and browser completely. After reopening the notebook my print statements worked again

It sounds like perhaps you ran afoul of the effect that just typing new code in a function cell does nothing. If you call that function again, it just runs the old code. You have to actually click “Shift-Enter” on the modified function cell in order to get the new code “compiled” (well, interpreted really) into the runtime code image. Or clicking “Kernel → Restart and Clear Output” followed by “Cell → Run All”. Or by closing the notebook and reopening it, which kills the runtime image altogether and forces a restart.

You can easily demonstrate this to yourself. Add an obvious bug (or a print statement) to a working function and then just call it again. It still works or still doesn’t print, right? Now click “Shift-Enter” on the function cell and run the test again. Kaboom! :scream_cat:

BTW this was discussed on the DLS FAQ Thread. If you missed that, it’s worth reading through everything there.