** A memorandum about "for _ in range ():" **.
Speaking of python for statement
sample1.py
for `variable` in `object`:
#Processing content
So, I think that "i", "j", "k", "loop", "iter", etc. are used for variables. On the other hand, the for statement may not use the loop variable for the processing content inside the for statement. At that time, by using ** "_ (underscore)" ** for the variable name of the for statement, it is possible to loop by the for statement without wasting the variable name.
sample2.py
for _ in `object`:
#Processing content
For example, like this. code
sample3.py
for _ in range(5):
print("Atcoder")
output
output3
Atcoder
Atcoder
Atcoder
Atcoder
Atcoder
I thought it would be unpleasant to specify a variable even though I wouldn't use it repeatedly in loop, so I'll use this in the future.
Recommended Posts