concept
Python Loops
Python Loops
Python Loops are Python’s main repetition tools. In Brevvie Python + AI — Section 2: Control Flow & The Treasure Hunt, loops are taught through room exploration, torch countdowns, and search tasks.
Loop types emphasized
forloops for walking lists, dicts, and other collectionswhileloops for repeated work controlled by a changing conditionenumerate()for pairing items with positions- list comprehensions as a concise loop-and-filter shortcut
Guidance from the source
Prefer for when you already have a collection. Use while when you truly need “keep going until something stops being true.”
See also Python Loop Types.