# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.float16.cloud/prompting/loop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
