Another option is to follow the advice on this blog: http://protips.maxmasnick.com/hide-code-when-sharing-ipython-notebooks
Specifically:
- Copy this code to the top (first cell) of your IPython notebook (copying code and comments directly from link above, all credit goes to the blogger):
import IPython.core.display as di
This line will hide code by default when the notebook is exported as HTML:
di.display_html('<script>jQuery(function() {if (jQuery("body.notebook_app").length == 0) { jQuery(".input_area").toggle(); jQuery(".prompt").toggle();}});</script>', raw=True)
This line will add a button to toggle visibility of code blocks, for use with the HTML export version:
di.display_html('''<button onclick="jQuery('.input_area').toggle(); jQuery('.prompt').toggle();">Toggle code</button>''', raw=True)
Run the top cell (with the above code in it). You should see "Toggle code" button right below it come up when it finished executing.
Click button to toggle the code off/on. The same toggling behavior will appear both in the .ipynb as well as the converted .html.