DEV Community

BC
BC

Posted on

Use _ to get the last evaluated value - Python Tips

In Python's interpreter, we can use _ to get the last evaluated value. This could be useful if you don't want to re-type the last evaluated value.

$ python3
Python 3.7.3 (default, Oct  7 2019, 12:56:13) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 + 2
3
>>> _
3
>>> 4 + _
7
>>>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)