🧩For Loop
Also known as for
A loop that runs once for each item in a list, then stops by itself.
Think of it like
Think of it like a teacher reading the names in class. Each name is called once, in order.
Example
A class app runs a for loop over 28 names. It sends each pupil the same reminder about the school trip.
Why it matters
Definition
Example code
python
for name in ["Emma", "Jack"]:
print("Hi", name)
# Hi Emma
# Hi JackCommon mistake
Key takeaways
- 1Once per item. Each item gets exactly one pass.
- 2Ends by itself. No items left means no more passes.
- 3A name for the item. A variable holds the current one.