> ## Documentation Index
> Fetch the complete documentation index at: https://site.aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# List

`function` **list.append**

<div class="code-block mt-5 mb-8 not-prose rounded-2xl relative group text-gray-950 dark:text-gray-50 codeblock-light border border-gray-950/10 dark:border-white/10 dark:twoslash-dark bg-transparent dark:bg-transparent" numberoflines="10" language="python">
  <div class="w-0 min-w-full max-w-full py-3.5 px-4 h-full dark:bg-codeblock relative text-sm leading-6 children:!my-0 children:!shadow-none children:!bg-transparent transition-[height] duration-300 ease-in-out [&_*]:ring-0 [&_*]:outline-none [&_*]:focus:ring-0 [&_*]:focus:outline-none [&_pre>code]:pr-[3rem] [&_pre>code>span.line-highlight]:min-w-[calc(100%+3rem)] [&_pre>code>span.line-diff]:min-w-[calc(100%+3rem)] rounded-2xl bg-white overflow-x-auto scrollbar-thin scrollbar-thumb-rounded scrollbar-thumb-black/15 hover:scrollbar-thumb-black/20 active:scrollbar-thumb-black/20 dark:scrollbar-thumb-white/20 dark:hover:scrollbar-thumb-white/25 dark:active:scrollbar-thumb-white/25" data-component-part="code-block-root" tabindex="0">
    <div class="font-mono whitespace-pre leading-6">
      <pre class="shiki shiki-themes github-light-default dark-plus" language="python">
        <code language="python">
          <span class="source python"><span class="meta function python"><span class="storage type function python">def</span> <span class="entity name function python"><span class="meta generic-name python">list</span></span>.<span class="entity name function python"><span class="meta generic-name python">append</span></span></span><span class="meta function parameters python"><span class="punctuation section parameters begin python">(</span></span><span class="meta function parameters python">
          <span class="variable parameter python">el</span></span><span class="meta function parameters annotation python"><span class="punctuation separator annotation parameter python">:</span> <a href="/axl/types/typing">typing</a><span class="punctuation accessor dot python">.</span><a href="/axl/types/typing">Any</a></span><span class="meta function parameters python"><span class="punctuation separator parameters python">,</span>
          /
          <span class="punctuation section parameters end python">)</span></span><span class="meta function python"> </span><span class="meta function annotation return python"><span class="punctuation separator annotation return python">-></span> <a href="/axl/types">None</a></span></span>
        </code>
      </pre>
    </div>
  </div>
</div>

[list.append](https://github.com/bazelbuild/starlark/blob/master/spec.md#list·append): append an element to a list.

`L.append(x)` appends `x` to the list L, and returns `None`.

`append` fails if the list is frozen or has active iterators.

```
x = []
x.append(1)
x.append(2)
x.append(3)
x == [1, 2, 3]
```

`function` **list.clear**

<div class="code-block mt-5 mb-8 not-prose rounded-2xl relative group text-gray-950 dark:text-gray-50 codeblock-light border border-gray-950/10 dark:border-white/10 dark:twoslash-dark bg-transparent dark:bg-transparent" numberoflines="10" language="python">
  <div class="w-0 min-w-full max-w-full py-3.5 px-4 h-full dark:bg-codeblock relative text-sm leading-6 children:!my-0 children:!shadow-none children:!bg-transparent transition-[height] duration-300 ease-in-out [&_*]:ring-0 [&_*]:outline-none [&_*]:focus:ring-0 [&_*]:focus:outline-none [&_pre>code]:pr-[3rem] [&_pre>code>span.line-highlight]:min-w-[calc(100%+3rem)] [&_pre>code>span.line-diff]:min-w-[calc(100%+3rem)] rounded-2xl bg-white overflow-x-auto scrollbar-thin scrollbar-thumb-rounded scrollbar-thumb-black/15 hover:scrollbar-thumb-black/20 active:scrollbar-thumb-black/20 dark:scrollbar-thumb-white/20 dark:hover:scrollbar-thumb-white/25 dark:active:scrollbar-thumb-white/25" data-component-part="code-block-root" tabindex="0">
    <div class="font-mono whitespace-pre leading-6">
      <pre class="shiki shiki-themes github-light-default dark-plus" language="python">
        <code language="python">
          <span class="source python"><span class="meta function python"><span class="storage type function python">def</span> <span class="entity name function python"><span class="meta generic-name python">list</span></span>.<span class="entity name function python"><span class="meta generic-name python">clear</span></span></span><span class="meta function parameters python"><span class="punctuation section parameters begin python">(</span></span><span class="meta function parameters python"><span class="punctuation section parameters end python">)</span></span><span class="meta function python"> </span><span class="meta function annotation return python"><span class="punctuation separator annotation return python">-></span> <a href="/axl/types">None</a></span></span>
        </code>
      </pre>
    </div>
  </div>
</div>

[list.clear](https://github.com/bazelbuild/starlark/blob/master/spec.md#list·clear): clear a list

`L.clear()` removes all the elements of the list L and returns `None`.
It fails if the list is frozen or if there are active iterators.

```
x = [1, 2, 3]
x.clear()
x == []
```

`function` **list.extend**

<div class="code-block mt-5 mb-8 not-prose rounded-2xl relative group text-gray-950 dark:text-gray-50 codeblock-light border border-gray-950/10 dark:border-white/10 dark:twoslash-dark bg-transparent dark:bg-transparent" numberoflines="10" language="python">
  <div class="w-0 min-w-full max-w-full py-3.5 px-4 h-full dark:bg-codeblock relative text-sm leading-6 children:!my-0 children:!shadow-none children:!bg-transparent transition-[height] duration-300 ease-in-out [&_*]:ring-0 [&_*]:outline-none [&_*]:focus:ring-0 [&_*]:focus:outline-none [&_pre>code]:pr-[3rem] [&_pre>code>span.line-highlight]:min-w-[calc(100%+3rem)] [&_pre>code>span.line-diff]:min-w-[calc(100%+3rem)] rounded-2xl bg-white overflow-x-auto scrollbar-thin scrollbar-thumb-rounded scrollbar-thumb-black/15 hover:scrollbar-thumb-black/20 active:scrollbar-thumb-black/20 dark:scrollbar-thumb-white/20 dark:hover:scrollbar-thumb-white/25 dark:active:scrollbar-thumb-white/25" data-component-part="code-block-root" tabindex="0">
    <div class="font-mono whitespace-pre leading-6">
      <pre class="shiki shiki-themes github-light-default dark-plus" language="python">
        <code language="python">
          <span class="source python"><span class="meta function python"><span class="storage type function python">def</span> <span class="entity name function python"><span class="meta generic-name python">list</span></span>.<span class="entity name function python"><span class="meta generic-name python">extend</span></span></span><span class="meta function parameters python"><span class="punctuation section parameters begin python">(</span></span><span class="meta function parameters python">
          <span class="variable parameter python">other</span></span><span class="meta function parameters annotation python"><span class="punctuation separator annotation parameter python">:</span> <a href="/axl/types/typing">typing</a><span class="punctuation accessor dot python">.</span><a href="/axl/types/typing">Iterable</a></span><span class="meta function parameters python"><span class="punctuation separator parameters python">,</span>
          /
          <span class="punctuation section parameters end python">)</span></span><span class="meta function python"> </span><span class="meta function annotation return python"><span class="punctuation separator annotation return python">-></span> <a href="/axl/types">None</a></span></span>
        </code>
      </pre>
    </div>
  </div>
</div>

[list.extend](https://github.com/bazelbuild/starlark/blob/master/spec.md#list·extend): extend a list with another iterable's content.

`L.extend(x)` appends the elements of `x`, which must be iterable, to
the list L, and returns `None`.

`extend` fails if `x` is not iterable, or if the list L is frozen or has
active iterators.

```
x = []
x.extend([1, 2, 3])
x.extend(["foo"])
x == [1, 2, 3, "foo"]
```

`function` **list.index**

<div class="code-block mt-5 mb-8 not-prose rounded-2xl relative group text-gray-950 dark:text-gray-50 codeblock-light border border-gray-950/10 dark:border-white/10 dark:twoslash-dark bg-transparent dark:bg-transparent" numberoflines="10" language="python">
  <div class="w-0 min-w-full max-w-full py-3.5 px-4 h-full dark:bg-codeblock relative text-sm leading-6 children:!my-0 children:!shadow-none children:!bg-transparent transition-[height] duration-300 ease-in-out [&_*]:ring-0 [&_*]:outline-none [&_*]:focus:ring-0 [&_*]:focus:outline-none [&_pre>code]:pr-[3rem] [&_pre>code>span.line-highlight]:min-w-[calc(100%+3rem)] [&_pre>code>span.line-diff]:min-w-[calc(100%+3rem)] rounded-2xl bg-white overflow-x-auto scrollbar-thin scrollbar-thumb-rounded scrollbar-thumb-black/15 hover:scrollbar-thumb-black/20 active:scrollbar-thumb-black/20 dark:scrollbar-thumb-white/20 dark:hover:scrollbar-thumb-white/25 dark:active:scrollbar-thumb-white/25" data-component-part="code-block-root" tabindex="0">
    <div class="font-mono whitespace-pre leading-6">
      <pre class="shiki shiki-themes github-light-default dark-plus" language="python">
        <code language="python">
          <span class="source python"><span class="meta function python"><span class="storage type function python">def</span> <span class="entity name function python"><span class="meta generic-name python">list</span></span>.<span class="entity name function python"><span class="meta generic-name python">index</span></span></span><span class="meta function parameters python"><span class="punctuation section parameters begin python">(</span></span><span class="meta function parameters python">
          <span class="variable parameter python">needle</span></span><span class="meta function parameters annotation python"><span class="punctuation separator annotation parameter python">:</span> <a href="/axl/types/typing">typing</a><span class="punctuation accessor dot python">.</span><a href="/axl/types/typing">Any</a></span><span class="meta function parameters python"><span class="punctuation separator parameters python">,</span>
          <span class="variable parameter python">start</span></span><span class="meta function parameters annotation python"><span class="punctuation separator annotation parameter python">:</span> <a href="/axl/types">None</a> <span class="keyword operator arithmetic python">|</span> <a href="/axl/types/int">int</a> </span><span class="meta function parameters default-value python"><span class="keyword operator assignment python">=</span> <span class="constant language python">None</span></span><span class="meta function parameters python"><span class="punctuation separator parameters python">,</span>
          <span class="variable parameter python">end</span></span><span class="meta function parameters annotation python"><span class="punctuation separator annotation parameter python">:</span> <a href="/axl/types">None</a> <span class="keyword operator arithmetic python">|</span> <a href="/axl/types/int">int</a> </span><span class="meta function parameters default-value python"><span class="keyword operator assignment python">=</span> <span class="constant language python">None</span></span><span class="meta function parameters python"><span class="punctuation separator parameters python">,</span>
          /
          <span class="punctuation section parameters end python">)</span></span><span class="meta function python"> </span><span class="meta function annotation return python"><span class="punctuation separator annotation return python">-></span> <a href="/axl/types/int">int</a></span></span>
        </code>
      </pre>
    </div>
  </div>
</div>

[list.index](https://github.com/bazelbuild/starlark/blob/master/spec.md#list·index): get the index of an element in the list.

`L.index(x[, start[, end]])` finds `x` within the list L and returns its
index.

The optional `start` and `end` parameters restrict the portion of
list L that is inspected.  If provided and not `None`, they must be list
indices of type `int`. If an index is negative, `len(L)` is effectively
added to it, then if the index is outside the range `[0:len(L)]`, the
nearest value within that range is used; see [Indexing](#indexing).

`index` fails if `x` is not found in L, or if `start` or `end`
is not a valid index (`int` or `None`).

```
x = ["b", "a", "n", "a", "n", "a"]
x.index("a") == 1      # bAnana
x.index("a", 2) == 3   # banAna
x.index("a", -2) == 5  # bananA
```

`function` **list.insert**

<div class="code-block mt-5 mb-8 not-prose rounded-2xl relative group text-gray-950 dark:text-gray-50 codeblock-light border border-gray-950/10 dark:border-white/10 dark:twoslash-dark bg-transparent dark:bg-transparent" numberoflines="10" language="python">
  <div class="w-0 min-w-full max-w-full py-3.5 px-4 h-full dark:bg-codeblock relative text-sm leading-6 children:!my-0 children:!shadow-none children:!bg-transparent transition-[height] duration-300 ease-in-out [&_*]:ring-0 [&_*]:outline-none [&_*]:focus:ring-0 [&_*]:focus:outline-none [&_pre>code]:pr-[3rem] [&_pre>code>span.line-highlight]:min-w-[calc(100%+3rem)] [&_pre>code>span.line-diff]:min-w-[calc(100%+3rem)] rounded-2xl bg-white overflow-x-auto scrollbar-thin scrollbar-thumb-rounded scrollbar-thumb-black/15 hover:scrollbar-thumb-black/20 active:scrollbar-thumb-black/20 dark:scrollbar-thumb-white/20 dark:hover:scrollbar-thumb-white/25 dark:active:scrollbar-thumb-white/25" data-component-part="code-block-root" tabindex="0">
    <div class="font-mono whitespace-pre leading-6">
      <pre class="shiki shiki-themes github-light-default dark-plus" language="python">
        <code language="python">
          <span class="source python"><span class="meta function python"><span class="storage type function python">def</span> <span class="entity name function python"><span class="meta generic-name python">list</span></span>.<span class="entity name function python"><span class="meta generic-name python">insert</span></span></span><span class="meta function parameters python"><span class="punctuation section parameters begin python">(</span></span><span class="meta function parameters python">
          <span class="variable parameter python">index</span></span><span class="meta function parameters annotation python"><span class="punctuation separator annotation parameter python">:</span> <a href="/axl/types/int">int</a></span><span class="meta function parameters python"><span class="punctuation separator parameters python">,</span>
          <span class="variable parameter python">el</span></span><span class="meta function parameters annotation python"><span class="punctuation separator annotation parameter python">:</span> <a href="/axl/types/typing">typing</a><span class="punctuation accessor dot python">.</span><a href="/axl/types/typing">Any</a></span><span class="meta function parameters python"><span class="punctuation separator parameters python">,</span>
          /
          <span class="punctuation section parameters end python">)</span></span><span class="meta function python"> </span><span class="meta function annotation return python"><span class="punctuation separator annotation return python">-></span> <a href="/axl/types">None</a></span></span>
        </code>
      </pre>
    </div>
  </div>
</div>

[list.insert](https://github.com/bazelbuild/starlark/blob/master/spec.md#list·insert): insert an element in a list.

`L.insert(i, x)` inserts the value `x` in the list L at index `i`,
moving higher-numbered elements along by one.  It returns `None`.

As usual, the index `i` must be an `int`. If its value is negative,
the length of the list is added, then its value is clamped to the
nearest value in the range `[0:len(L)]` to yield the effective index.

`insert` fails if the list is frozen or has active iterators.

```
x = ["b", "c", "e"]
x.insert(0, "a")
x.insert(-1, "d")
x == ["a", "b", "c", "d", "e"]
```

`function` **list.pop**

<div class="code-block mt-5 mb-8 not-prose rounded-2xl relative group text-gray-950 dark:text-gray-50 codeblock-light border border-gray-950/10 dark:border-white/10 dark:twoslash-dark bg-transparent dark:bg-transparent" numberoflines="10" language="python">
  <div class="w-0 min-w-full max-w-full py-3.5 px-4 h-full dark:bg-codeblock relative text-sm leading-6 children:!my-0 children:!shadow-none children:!bg-transparent transition-[height] duration-300 ease-in-out [&_*]:ring-0 [&_*]:outline-none [&_*]:focus:ring-0 [&_*]:focus:outline-none [&_pre>code]:pr-[3rem] [&_pre>code>span.line-highlight]:min-w-[calc(100%+3rem)] [&_pre>code>span.line-diff]:min-w-[calc(100%+3rem)] rounded-2xl bg-white overflow-x-auto scrollbar-thin scrollbar-thumb-rounded scrollbar-thumb-black/15 hover:scrollbar-thumb-black/20 active:scrollbar-thumb-black/20 dark:scrollbar-thumb-white/20 dark:hover:scrollbar-thumb-white/25 dark:active:scrollbar-thumb-white/25" data-component-part="code-block-root" tabindex="0">
    <div class="font-mono whitespace-pre leading-6">
      <pre class="shiki shiki-themes github-light-default dark-plus" language="python">
        <code language="python">
          <span class="source python"><span class="meta function python"><span class="storage type function python">def</span> <span class="entity name function python"><span class="meta generic-name python">list</span></span>.<span class="entity name function python"><span class="meta generic-name python">pop</span></span></span><span class="meta function parameters python"><span class="punctuation section parameters begin python">(</span></span><span class="meta function parameters python">
          <span class="variable parameter python">index</span></span><span class="meta function parameters annotation python"><span class="punctuation separator annotation parameter python">:</span> <a href="/axl/types/int">int</a> </span><span class="meta function parameters default-value python"><span class="keyword operator assignment python">=</span> <span class="constant language python">...</span></span><span class="meta function parameters python"><span class="punctuation separator parameters python">,</span>
          /
          <span class="punctuation section parameters end python">)</span></span><span class="meta function python"> </span><span class="meta function annotation return python"><span class="punctuation separator annotation return python">-></span> <a href="/axl/types/typing">typing</a><span class="punctuation accessor dot python">.</span><a href="/axl/types/typing">Any</a></span></span>
        </code>
      </pre>
    </div>
  </div>
</div>

[list.pop](https://github.com/bazelbuild/starlark/blob/master/spec.md#list·pop): removes and returns the last element of a list.

`L.pop([index])` removes and returns the last element of the list L, or,
if the optional index is provided, at that index.

`pop` fails if the index is negative or not less than the length of
the list, of if the list is frozen or has active iterators.

```
x = [1, 2, 3]
x.pop() == 3
x.pop() == 2
x == [1]
```

`function` **list.remove**

<div class="code-block mt-5 mb-8 not-prose rounded-2xl relative group text-gray-950 dark:text-gray-50 codeblock-light border border-gray-950/10 dark:border-white/10 dark:twoslash-dark bg-transparent dark:bg-transparent" numberoflines="10" language="python">
  <div class="w-0 min-w-full max-w-full py-3.5 px-4 h-full dark:bg-codeblock relative text-sm leading-6 children:!my-0 children:!shadow-none children:!bg-transparent transition-[height] duration-300 ease-in-out [&_*]:ring-0 [&_*]:outline-none [&_*]:focus:ring-0 [&_*]:focus:outline-none [&_pre>code]:pr-[3rem] [&_pre>code>span.line-highlight]:min-w-[calc(100%+3rem)] [&_pre>code>span.line-diff]:min-w-[calc(100%+3rem)] rounded-2xl bg-white overflow-x-auto scrollbar-thin scrollbar-thumb-rounded scrollbar-thumb-black/15 hover:scrollbar-thumb-black/20 active:scrollbar-thumb-black/20 dark:scrollbar-thumb-white/20 dark:hover:scrollbar-thumb-white/25 dark:active:scrollbar-thumb-white/25" data-component-part="code-block-root" tabindex="0">
    <div class="font-mono whitespace-pre leading-6">
      <pre class="shiki shiki-themes github-light-default dark-plus" language="python">
        <code language="python">
          <span class="source python"><span class="meta function python"><span class="storage type function python">def</span> <span class="entity name function python"><span class="meta generic-name python">list</span></span>.<span class="entity name function python"><span class="meta generic-name python">remove</span></span></span><span class="meta function parameters python"><span class="punctuation section parameters begin python">(</span></span><span class="meta function parameters python">
          <span class="variable parameter python">needle</span></span><span class="meta function parameters annotation python"><span class="punctuation separator annotation parameter python">:</span> <a href="/axl/types/typing">typing</a><span class="punctuation accessor dot python">.</span><a href="/axl/types/typing">Any</a></span><span class="meta function parameters python"><span class="punctuation separator parameters python">,</span>
          /
          <span class="punctuation section parameters end python">)</span></span><span class="meta function python"> </span><span class="meta function annotation return python"><span class="punctuation separator annotation return python">-></span> <a href="/axl/types">None</a></span></span>
        </code>
      </pre>
    </div>
  </div>
</div>

[list.remove](https://github.com/bazelbuild/starlark/blob/master/spec.md#list·remove): remove a value from a list

`L.remove(x)` removes the first occurrence of the value `x` from the
list L, and returns `None`.

`remove` fails if the list does not contain `x`, is frozen, or has
active iterators.

```
x = [1, 2, 3, 2]
x.remove(2)
x == [1, 3, 2]
x.remove(2)
x == [1, 3]
```

A subsequent call to `x.remove(2)` would yield an error because the
element won't be found.

```
x = [1, 2, 3, 2]
x.remove(2)
x.remove(2)
x.remove(2) # error: not found
```
