# append-to-list

## Description

<mark style="color:purple;">`append-to-list`</mark> *adaptor adds a single new value to the end of an existing list, or to a new list if the* `list` *input is not specified*.

If you wish to add a value to the beginning of a list, use the [<mark style="color:purple;">`prepend-to-list`</mark> ](https://cgps.gitbook.io/data-flo/reference-guide/prepend-to-list)adaptor. If you wish to add multiple values, use the [<mark style="color:purple;">`append-lists`</mark> ](https://cgps.gitbook.io/data-flo/reference-guide/append-lists)adaptor.

## Inputs

**`list`**\
Type: `list`\
Required: No\
The list to which the values will be appended. If not specified, the value will be added to a new list.

**`value`**\
Type: `text`\
Required: Yes\
The value to be appended to the list.

## Outputs

**`list`**\
Type: `list`\
A list with the value appended.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`value`:

1. `blue`

#### Outputs:

`list`:

1. `blue`

-> Added value `blue` to the end of a new list.

### Example 2: Adding a value to an existing list.

#### Inputs:

`list`:

1. `red`
2. `green`

`value`:

1. `blue`

#### Outputs:

`list`:

1. `red`
2. `green`
3. `blue`

-> Added value `blue` to the end of an existing list.

## Use Cases

* Add a new species to a list of reportable illnesses.
* After using the [<mark style="color:purple;">`sort list`</mark> ](https://cgps.gitbook.io/data-flo/reference-guide/sort-list)adaptor, add a missing element to the end of the list.
* Adding new values to lists allows for adjustment of included values without modifying the original dataset.
* Users might need to dynamically add new values to a list based on changing programme priorities or newly mapped values, or missed/forgotten values to include.
* Allows for users to include additional observations, experiment with different scenarios, or respond to changes in the data.
* Lists are often used to keep track of records or historical data. Adding new values ensures that the record is comprehensive and up-to-date.


---

# 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://cgps.gitbook.io/data-flo/reference-guide/append-to-list.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.
