Index Ai Academy
Glossary · Phase 0 · Tools

Loop

Also written: loops, for loop, while loop

Code that repeats: for each item in a list, or while something stays true.

Try it now

Watch spend take each value in turn while total grows. The loop body (line 4) runs four times, then Python moves on to the print.

Learn it properly

Loops · Repeat work over every item without copy-pasting code. About 25 minutes.

Start this free lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write