About "for _ in range ():" in python

** 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

About "for _ in range ():" in python
About Python, for ~ (range)
About python, range ()
About Python for loops
About __all__ in python
About Fabric's support for Python 3
Think about architecture in python
Search for strings in Python
Techniques for sorting in Python
Check for external commands in python
About dtypes in Python and Cython
I learned about processes in Python
Run unittests in Python (for beginners)
2016-10-30 else for Python3> for:
About python slices
Quadtree in Python --2
python [for myself]
CURL in python
About python comprehension
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
About Python tqdm.
Unittest in python
About python yield
How about Anaconda for building a machine learning environment in Python?
Notes on nfc.ContactlessFrontend () for nfcpy in python
Inject is recommended for DDD in Python
About python, class
Tips for dealing with binaries in Python
Summary of various for statements in Python
Type annotations for Python2 in stub files!
Discord in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
About python inheritance
Programming in python
Process multiple lists with for in Python
Plink in Python
Constant in python
MongoDB for the first time in Python
About python decorators
Get a token for conoha in python
Lifegame in Python.
Sample for handling eml files in Python
Sqlite in python
StepAIC in Python
AtCoder cheat sheet in python (for myself)
N-gram in python
I searched for prime numbers in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Tips for making small tools in python
Constant in python
Use pathlib in Maya (Python 2.7) for upcoming Python 3.7