The default output of jupyter notebook/lab only displays the variables
in the last line. Add at the top of the file:
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
You can output and display each line of code
If you want to restore the default, just change it as follows:
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "none"