repeat loop
A for loop over range(n) whose only purpose is to run its block n times.
In more detail
The loop variable is not used inside the body, so it is often named _. Letting the user type the count, as in range(int(input())), turns it into a flexible repeater.
Related terms
- for loop — A loop that runs its body once for each item in a list or other collection, setting a loop variable to the current item.
- range() — A built-in that produces a sequence of whole numbers on demand, such as range(5) for 0, 1, 2, 3, 4.
- underscore variable — The name _, used by convention for a value you must receive but will never use, as in for _ in range(3).
Taught in
- Repeat Loops And Successive Modification — Hands-on Python: Complete Video Course & Book
- Chapter One In One Sitting — Hands-on Python: Complete Video Course & Book
- Mad Libs Revisited: Finding The Cues — Hands-on Python: Complete Video Course & Book
- Animation: Loops, Bouncing, Flushing — Hands-on Python: Complete Video Course & Book
- Interactive While Loops — Hands-on Python: Complete Video Course & Book