Why we use _ in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we use _ in python?

3rd Oct 2018, 1:36 PM
Manav Malhotra
Manav Malhotra - avatar
2 Answers
+ 2
you cannot define a variable with space. x y=5 #its wrong but x_y=5 #its right. it's also use for if you want to define a variable with a name which is already built in function in python. e.g sum=4 #wrong because sum is built in function in python. _sum=4 #right it's also use in oop to tell the another programmer that this variable or function is private don't touch it. _y=10 or def _h(): #private remember it's just convention to tell the another programmer but actual it is not a private.
3rd Oct 2018, 3:56 PM
Maninder $ingh
Maninder $ingh - avatar