# Change a list

> Add to, remove from, sort, shuffle or empty a list variable.

Source: https://docs.buildcord.dev/nodes/variables-and-data/change-list/

`data.list` changes a [variable](https://docs.buildcord.dev/concepts/data) of the **list** type, whose items are separated by commas.

## Settings

| Setting | What it does |
| --- | --- |
| List variable | The variable to change. |
| Do | Add items, add items it doesn't have, remove an item, remove the item at a position, take the last item off, sort it, shuffle it, drop repeats, or empty it. |
| Item | What to add (several separated by commas) or remove, or a position: from 1, or -1 for the last. |

## Ways out

`out`. Turn on **If it fails** for a red way out.

## Produces

| Token | Value |
| --- | --- |
| `{list.count}` | How many items it has now |
| `{list.item}` | What was just removed by position or taken off the end |

## Notes

- Runs changing the same list take turns, so two members joining a queue at once both end up on it.
- Removing an item ignores capitals and removes every copy.
- Read the list anywhere as `{var.name}`, loop over it with [For each item](https://docs.buildcord.dev/nodes/flow-control/for-each), and test it with **is one of** in a [Comparison](https://docs.buildcord.dev/nodes/conditions/comparison).
- Items can't contain commas.

## Example

A `/queue join` command adds `{user.id}` with **Add items it doesn't have**; `/queue next` takes the first item off with **Remove the item at a position** and `1`, and pings `<@{list.item}>`.

## Related

- [Manipulate text](https://docs.buildcord.dev/nodes/variables-and-data/manipulate-text), for list functions that don't change the variable
- [Pick at random](https://docs.buildcord.dev/nodes/variables-and-data/pick-at-random)
