I have an imported function that runs in an IPython notebook (input cell X) which produces an output (in output cell X). After the function runs, I have some more code (also
You can get the output of the cell X by using _
or Out[X]
. Such as:
In [1]: 2 + 35
Out[1]: 37
In [2]: _ + 3
Out[2]: 40
In [3]: lst = [i for i in range(5)]
lst
Out[3]: [0, 1, 2, 3, 4]
In [4]: Out[1] #Using the output of Cell 1
Out[4]: 37
In [5]: Out[3][1] #Using the output of Cell 3
Out[5]: 1
Here, If you want to get the output of the previous cell, then you can use _
. You can use two (__
) or three underscores(___
) as well to refer to output of the next previous and next-next previous cells respectively.
However, if you have many cells in the notebook and you want to refer some particular cell, then Out[X]
will be helpful.