# Standard Loop

Standard loop is used to append new rows to your table.

**Suitable for**

* Saving new data - example: scraping a list of profiles from a public website.
* Performing static actions - example: repeatedly pressing keyboard tab key.

**Key characteristics**

* Creates new rows in your table. Creates means appends.
* Can manipulate the data in the rows that are appended during the loop. For example, you can add building blocks like *Format Data* to transform the format of the data that you are saving. Whatever actions your TaskBot takes during a loop iteration, they will all be applied to the same to-be-appended row.
* Ignores any existing data in your tables. If you need to refer to the existing data, use variables, which are loop-independent (or, if applicable, select dynamic loop type, see [dynamic-loop](https://docs.zerowork.io/using-zerowork/using-building-blocks/start-repeat/dynamic-loop "mention")).
* Automatically scrolls if the data is displayed in an endless scroll (unless you select auto-detect option, see here: [continue-until-no-element-is-found](https://docs.zerowork.io/using-zerowork/using-building-blocks/start-repeat/continue-until-no-element-is-found "mention")!).

#### Example set-up

See [save-lists](https://docs.zerowork.io/using-zerowork/using-building-blocks/save-web-element/save-lists "mention") (link includes video tutorial).

### How to Use Loop Index Syntax to Save Lists of Public Data

Once you review the example above (here is the same link again: [save-lists](https://docs.zerowork.io/using-zerowork/using-building-blocks/save-web-element/save-lists "mention")), you will see that the list selector contains <mark style="color:red;">**{loop\_index}**</mark>, so that TaskBot can iterate over items in the list.

Selectors of items in a list contain a number by which they increment, as described here: [lists-incremental-css-selectors](https://docs.zerowork.io/using-zerowork/using-selectors/how-to-build-custom-selectors/lists-incremental-css-selectors "mention"). In place of that number, you need to insert **{loop\_index}**. Same principle applies both to CSS and XPath selectors.

Here is how to do that.

**Step 1**: Simply copy two to three selectors from the list you want to save. As an example, consider these are the first three selectors from the list that you copied.

Original:

* **1st  result  in the list:** main#main li:nth-child(<mark style="color:red;">**1**</mark>) > div.abi-saved-contacts-row\_\_details > button\[type='button'] > div > div > span
* **2nd result in the list:** main#main li:nth-child(<mark style="color:red;">**2**</mark>) > div.abi-saved-contacts-row\_\_details > button\[type='button'] > div > div > span
* **3rd result in the list:** main#main li:nth-child(<mark style="color:red;">**3**</mark>) > div.abi-saved-contacts-row\_\_details > button\[type='button'] > div > div > span

Notice how all the selectors in the list will display an incremental number (highlighted in red above).

**Step 2**: Substitute the incremental number by loop index.

main#main li:nth-child(<mark style="color:red;">**{loop\_index}**</mark>) > div.abi-saved-contacts-row\_\_details > button\[type='button'] > div > div > span

#### Alternative way if you don't know where exactly the increment takes place:

main#main li\~\~<mark style="color:red;">**:nth-child(1)**</mark>\~\~ > div.abi-saved-contacts-row\_\_details > button\[type='button'] > div > div > span <mark style="color:red;">**>> nth={loop\_index}**</mark>

In this case, we are using a filter (>>), as described here: [combine-filters-with-standard-css-logic](https://docs.zerowork.io/using-zerowork/using-selectors/how-to-build-custom-selectors/combine-filters-with-standard-css-logic "mention").&#x20;

#### Starting point

Optionally, you can specify your starting point like this: <mark style="color:red;">**{loop\_index,2}**</mark> where 2 means that the count should start from the 2nd element.

Note that the :nth-child() method starts count from 1, whereas the >> nth= method starts count from 0 (0 corresponds to the 1st element in the list, 1 to the 2nd, etc.).

#### Special case: Skip items

In rare cases, a list might skip some numbers. For example, consider this list:

* **1st  result  in the list:** main#main li:nth-child(<mark style="color:red;">**1**</mark>) > div.abi-saved-contacts-row\_\_details > button\[type=“button“] > div > div > span
* **2nd result in the list:** main#main li:nth-child(<mark style="color:red;">**3**</mark>) > div.abi-saved-contacts-row\_\_details > button\[type=“button“] > div > div > span
* **3rd result in the list:** main#main li:nth-child(<mark style="color:red;">**5**</mark>) > div.abi-saved-contacts-row\_\_details > button\[type=“button“] > div > div > span

In this case, you can use this syntax: <mark style="color:red;">**{loop\_index,1,2}**</mark>, where the additional number (in this case it's 2) means that two elements should be always skipped when incrementing the loop index.

#### Advanced use: Referencing the loop index of a parent loop

You can add a loop ID like this: <mark style="color:red;">**{loop\_index\_123}**</mark>, where 123 corresponds to the ID of the Start Repeat building block.

This is useful when you need to reference the loop index of a parent loop. A common use case is when looping through web tables: the parent loop iterates over rows, and the child loop iterates over columns — allowing selectors to access both the parent and child loop indices.
