+ 1

How this underscore work in python?

Using the underscore means the last output... >>> x=10 >>> x + 9 19 >>> _ + x 29 Can underscore take any type of output? For example: function

11th Jan 2021, 7:03 AM
Hushnudbek
Hushnudbek - avatar
3 Réponses
+ 4
Hushnudbek it's just a variable with name '_' It can hold everything any other variable can.
11th Jan 2021, 8:42 AM
Arsenic
Arsenic - avatar
+ 1
Python interpreter stores last expression in a special variable named '_' In your case it has value 19. you can also use underscore as a variable name anywhere else.
11th Jan 2021, 7:22 AM
Arsenic
Arsenic - avatar
0
Can it take function?
11th Jan 2021, 7:25 AM
Hushnudbek
Hushnudbek - avatar