# Run a loop

> Repeat the steps that follow a set number of times, or once for each item in a list.

Source: https://docs.buildcord.dev/nodes/flow-control/loop/

`flow.loop` repeats the steps wired to **Each time**, then continues from **When finished**. It can't fail.

> **Note: No longer in the picker**
>
> [Repeat](https://docs.buildcord.dev/nodes/flow-control/repeat) and [For each item](https://docs.buildcord.dev/nodes/flow-control/for-each) each do one half of it, so a node never reads two ways at once. Flows that have this node keep working.

## Settings

| Setting | What it does |
| --- | --- |
| Times | How many passes. The default is 3. The current pass is `{loop.index}`, starting at 1. |
| Or once for each item in | A list, such as `{var.bannedWords}`. When set, each item is `{loop.item}`, and blank items are skipped. |
| Items are separated by | **Commas** or **New lines**. |

## Ways out

| Way out | Taken when |
| --- | --- |
| `Each time` | For every pass. Wire it to the steps to repeat. |
| `When finished` | After the last pass. |

## Produces

`{loop.index}`, and `{loop.item}` when you give a list.

## Notes

- A path inside the loop that leads nowhere returns control to the loop for its next pass.
- Use [Stop a loop](https://docs.buildcord.dev/nodes/flow-control/stop-loop) to leave early.
- To loop over rows of a collection, use [For each row](https://docs.buildcord.dev/nodes/variables-and-data/for-each-row).

## Example

Check a message against each word in `{var.bannedWords}` and stop the loop at the first match.

## Related

- [Stop a loop](https://docs.buildcord.dev/nodes/flow-control/stop-loop)
- [For each row](https://docs.buildcord.dev/nodes/variables-and-data/for-each-row)
