How to print all the output of a cell in Jupyter notebook.

Normally, Jupyter notebook only displays the last output of the cell; all others are ignored unless you use the print() function (for Python 3).

For example:


Jupyter only displays the following as the output:


3, the output for 1+2 gets totally ignored. The simple hack below will fix this.

from IPython.core.interactiveshell import InteractiveShell  InteractiveShell.ast_node_interactivity = "all"

Basically, put the code above in the beginning of your notebook and voilà, all the output is printed.


Author: Ednalyn C. De Dios

I’ve always been enamored with code and I love data science because of its inherent power to solve real problems. Having grown up in the Philippines, served in the United States Navy, and worked in the nonprofit sector, I am driven to make the world a better place. I have started and participated in numerous campaigns that aim to reduce domestic violence and child abuse in the community.