AI engineering glossary · Python core

What is for loop?

for loop: A loop that runs its block once for each item of an iterable such as a list, string, dictionary or range, assigning the current item to a loop variable. It is used when the number of repetitions follows from the data.

Level: beginnerTopic: Python core

for loop: an example

for city in ['Delhi', 'Chennai']: print(city) prints each name on its own line.

Related terms

More Python core terms

Where you learn it

for loop is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.