Edward Z. Yang Edward Z. Yang - 3 months ago 26
Python Question

Get last answer

In many symbolic math systems, such as Matlab or Mathematica, you can use a variable like

Ans
or
%
to retrieve the last computed value. Is there a similar facility in the Python shell?

Answer

Underscore.

>>> 5+5
10
>>> _
10
>>> _ + 5
15
>>> _
15
Comments