loop variable
The name in a for heading that takes each item of the sequence in turn, as item in for item in items.
In more detail
It is an ordinary variable, reassigned at the start of every pass, and it keeps its last value after the loop. If you never use it, name it _ to say so.
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.
- 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
- Lists, Range And The For Loop — Hands-on Python: Complete Video Course & Book
- Repeat Loops And Successive Modification — Hands-on Python: Complete Video Course & Book
- Accumulation Loops — Hands-on Python: Complete Video Course & Book
- While, For, Range And The Loop Else — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Twelve Traps, One Shape Each — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- List Comprehensions, Filtered And Nested — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Closures: Functions That Remember — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Comprehensions, Closures And Files Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Twelve Traps, Mostly Objects — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep