# Loop

### Intro

LLMs have the ability to loop based on a modifier or condition to determine the action.

### How it work ?

LLMs can operate step by step. The number of loops can be defined by a specific number or can loop through the entire data.

```
food list = []

Add food name into food list 10 times.
```

{% hint style="info" %}
A software developer could consider this ability similar to the **Loop** functionality in other programming languages.
{% endhint %}

### Prompt example

{% embed url="<https://prompt.float16.cloud/prompt/e8c57ab1-73ce-4a7c-a816-9a69f239269f>" %}
Iterative add name of food
{% endembed %}

{% embed url="<https://prompt.float16.cloud/prompt/d1d2fe39-f3fc-4a0b-96b1-aebb75627dce>" %}
Iterative loop with condition
{% endembed %}

{% embed url="<https://prompt.float16.cloud/prompt/5832987b-1b91-4737-8b99-56aaab5a2a24>" %}
Iterative loop and stop (While loop)
{% endembed %}

{% embed url="<https://prompt.float16.cloud/prompt/51ee2c08-048c-43cd-af59-9cb9d3527fcc>" %}
Iterative loop and stop (For loop)
{% endembed %}
