"""Use of _ as a variable
It is to indicate throwaway variables,
...i.e. variables that are not reused anywhere else (as they are...
...not logically important) but for syntax reasons you have to put
This saves space for variables that are actually reused...
...and provides a good mental model for essential and unessential parts...
...of your code
Of course, take this as a guideline.
There are instances where naming those variables are better for readability...
...especially in group projects
Check out the source for more info!
"""
lst1 = [_ for _ in range(10)]
print(lst1)
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print(7//3) # Returns the Quotient
print(7/3) # Returns Division
_ #is used in the interactive interpreter to store the result of the last evaluation
_/2 # Valid in operation
>>> a = 10
>>> b = 10
>>> _
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '_' is not defined
>>> a+b
20
>>> _
20
>>> _ * 2
40
>>> _
40
>>> _ / 2
20