Python – Get last result in interactive Python shell

python

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?

Best Solution

Underscore.

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