Python for-loop without index and item
While @toine is completly right about using _
, you could also refine this by means of a list comprehension:
list_1 = [3 for _ in range(5)]
This avoids the ITM ("initialize, than modify") anti-pattern.
You can replace i
with _
to make it an 'invisible' variable.
See related: What is the purpose of the single underscore "_" variable in Python?.