Runtime v2.81 · Updated Sep 30, 2026

list

An ordered collection you can create, read, loop through, destructure, and update while the script runs.

Syntax

list(iterable=(), /)

Parameters

None

Returns

list

Behavior / side effects

An ordered collection you can create, read, loop through, destructure, and update while the script runs.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = list()
numbers.append(2)
numbers.extend([0, 3])
first = numbers[0]        # returns 2
count = len(numbers)      # returns 3

for value in numbers:
    wait(50)              # returns None

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

None

Methods

22 methods

list.constructor

Create an empty list or copy the items from one iterable into a new mutable list.

Syntax

list()
list(iterable, /)

Parameters

NameDescription
iterableIterable
Source values to copy into the new list.
Depends on overload · Positional only
Default: ()

Returns

list — A new mutable list.

Behavior / side effects

Create an empty list or copy the items from one iterable into a new mutable list.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = list()
numbers.append(2)
numbers.append(3)

copied = list(numbers)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.literal

Create a list literal inline.

Syntax

[1, 2, 3]

Parameters

NameDescription
itemAny?
Each item written inside the brackets.
Required · Positional or named
No default

Returns

list — A new mutable list preserving the literal order.

Behavior / side effects

Create a list literal inline. This is the shortest form when you already know the items.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [2, 0, 3]
first = numbers[0]       # returns 2

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.comprehension

Build a list by looping through another iterable.

Syntax

[expr for target in iterable if condition]

Parameters

NameDescription
exprAny?
Value to append for each accepted item.
Required · Positional or named
No default
targetName | destructuring target
Loop target for the current item. Starred targets are not supported.
Required · Positional or named
No default
iterableIterable
Source values to loop through.
Required · Positional or named
No default
conditionBoolean
Optional filter checked before appending.
Optional · Positional only
Default: True

Returns

list — A new mutable list with matching items in iteration order.

Behavior / side effects

Build a list by looping through another iterable. Multiple for/if clauses are supported, and loop targets stay local to the comprehension.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

values = [1, 2, 3, 4]
evens = [x for x in values if x % 2 == 0]

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.range_source

Create a new integer list for loops, counters, and numeric ranges.

Syntax

range(stop, /) | range(start, stop, step=1, /)

Parameters

NameDescription
startNumber
Start value (inclusive).
Depends on overload · Positional only
Default: 0
stopNumber
End value (exclusive).
Required · Positional only
No default
stepNumber
Increment between items. Cannot be 0.
Depends on overload · Positional only
Default: 1

Returns

list[Int] — A new integer list.

Behavior / side effects

Create a new integer list for loops, counters, and numeric ranges.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = range(5)         # returns [0, 1, 2, 3, 4]
evens = range(0, 10, 2)   # returns [0, 2, 4, 6, 8]

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.length

Count how many items are in the list.

Syntax

len(list, /)

Parameters

NameDescription
listlist
The list to count.
Required · Positional only
No default

Returns

Int — Number of items in the list.

Behavior / side effects

Count how many items are in the list.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = range(3, 8)     # returns [3, 4, 5, 6, 7]
count = len(numbers)      # returns 5

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.index_access

Read one item by index.

Syntax

list[index]

Parameters

NameDescription
listlist
The source list.
Required · Positional or named
No default
indexInt
Item index. Use -1 for the last item.
Required · Positional only
No default

Returns

Any? — The item at that position. Raises IndexError when the index is outside the list.

Behavior / side effects

Read one item by index. Negative indexes count from the end.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = range(10, 15)   # returns [10, 11, 12, 13, 14]
first = numbers[0]        # returns 10
third = numbers[2]        # returns 12
last = numbers[-1]        # returns 14

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.slice

Copy part of a list using Python-style slicing.

Syntax

list[start:end[:step]]

Parameters

NameDescription
startInt
First item index to include.
Optional · Positional only
Default: start of list
endInt
Stop before this item index.
Optional · Positional only
Default: end of list
stepInt
Distance between items. Cannot be 0; negative values read backward.
Optional · Positional only
Default: 1

Returns

list — A new mutable list slice, clamped to the available range.

Behavior / side effects

Copy part of a list using Python-style slicing. Omitted bounds use the start or end; negative indexes count from the end.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [0, 1, 2, 3, 4]
middle = numbers[1:4]     # returns [1, 2, 3]
tail = numbers[-2:]       # returns [3, 4]
reverse = numbers[::-1]   # returns [4, 3, 2, 1, 0]

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.index_assignment

Replace one existing item by index.

Syntax

list[index] = value

Parameters

NameDescription
listlist
The mutable list to update.
Required · Positional or named
No default
indexInt
Item index that already exists. Use -1 for the last item.
Required · Positional only
No default
valueAny?
New value to store at that position.
Required · Positional only
No default

Returns

None — No direct return value. The list is updated in place.

Behavior / side effects

Replace one existing item by index. Negative indexes count from the end. The index must already be inside the list.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [12, 12, 21, 3, 2, 1]
numbers[4] = 3            # numbers becomes [12, 12, 21, 3, 3, 1]

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.destructuring_assignment

Unpack list items into matching assignment targets.

Syntax

a, b = list

Parameters

NameDescription
a, bTargets
Assignment targets matching the list item count.
Required · Positional or named
No default
listlist
Source list to unpack.
Required · Positional only
No default

Returns

None — No direct return value. Targets receive list items left to right.

Behavior / side effects

Unpack list items into matching assignment targets. Nested targets are supported, but starred targets such as *rest are not supported.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

point = [500, 900]
x, y = point

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.append

Add one new item to the end of the list.

Syntax

list.append(value, /)

Parameters

NameDescription
valueAny?
The value to add.
Required · Positional only
No default

Returns

None — No direct return value. The list is updated in place.

Behavior / side effects

Add one new item to the end of the list.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [2, 0]
numbers.append(3)
last = numbers[-1]        # returns 3

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.extend

Append every item from another iterable to the end of the current list.

Syntax

list.extend(iterable, /)

Parameters

NameDescription
iterableIterable
Source values whose items will be appended.
Required · Positional only
No default

Returns

None — No direct return value. The list grows in place.

Behavior / side effects

Append every item from another iterable to the end of the current list.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [1]
numbers.extend([2, 3])
count = len(numbers)      # returns 3

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.insert

Insert one item before the given index.

Syntax

list.insert(index, value, /)

Parameters

NameDescription
indexInt
Position before which the value is inserted.
Required · Positional only
No default
valueAny?
The value to insert.
Required · Positional only
No default

Returns

None — No direct return value. The list is updated in place.

Behavior / side effects

Insert one item before the given index. Negative and oversized indexes are clamped like Python.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [1, 3]
numbers.insert(1, 2)      # numbers becomes [1, 2, 3]

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.remove

Remove the first item whose value matches the given value.

Syntax

list.remove(value, /)

Parameters

NameDescription
valueAny?
Value to find and remove from the list.
Required · Positional only
No default

Returns

None — No direct return value. Raises ValueError when the value is not found.

Behavior / side effects

Remove the first item whose value matches the given value.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [1, 2, 2, 3]
numbers.remove(2)         # numbers becomes [1, 2, 3]

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.pop

Remove one item from the list and return it.

Syntax

list.pop(index=-1, /)

Parameters

NameDescription
indexInt
Optional index to remove. Negative indexes count from the end.
Optional · Positional only
Default: -1

Returns

Any? — The removed item. Raises IndexError when the list is empty or the index is outside the list.

Behavior / side effects

Remove one item from the list and return it. Omitting the index removes the last item.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [2, 0, 3]
removed = numbers.pop()   # returns 3
first = numbers.pop(0)    # returns 2

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.clear

Remove every item from the list.

Syntax

list.clear()

Parameters

None

Returns

None — No direct return value. The list becomes empty.

Behavior / side effects

Remove every item from the list.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [2, 0, 3]
numbers.clear()
text(str(len(numbers)))   # returns 0

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.index

Return the first index whose item equals value within the optional start and stop bounds.

Syntax

list.index(value, start=0, stop=len(list), /)

Parameters

NameDescription
valueAny?
Value to search for.
Required · Positional only
No default
startInt
Optional start bound. Negative values count from the end.
Optional · Positional only
Default: 0
stopInt
Optional stop bound. The item at this index is not included.
Optional · Positional only
Default: len(list)

Returns

Int — The matching index. Raises ValueError when the value is not found.

Behavior / side effects

Return the first index whose item equals value within the optional start and stop bounds.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [1, 2, 1, 3]
first_one = numbers.index(1)       # returns 0
later_one = numbers.index(1, 1)    # returns 2

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.count

Count how many items equal the given value.

Syntax

list.count(value, /)

Parameters

NameDescription
valueAny?
Value to count.
Required · Positional only
No default

Returns

Int — Number of matching items.

Behavior / side effects

Count how many items equal the given value.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [1, 2, 1, 3]
ones = numbers.count(1)   # returns 2

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.sort

Sort the list in place using the same stable ordering rules as sorted().

Syntax

list.sort(*, key=None, reverse=False)

Parameters

NameDescription
keyCallable?
Optional function that returns the comparison key for each item.
Optional · Keyword only
Default: None
reverseBoolean
When true, sort from largest to smallest.
Optional · Keyword only
Default: False

Returns

None — No direct return value. The list is reordered in place.

Behavior / side effects

Sort the list in place using the same stable ordering rules as sorted().

Execution

  • Blocking: Conditional
  • Thread safety: Use separate objects per flow
  • Parallel execution: Conditional

The operation processes values in the calling flow. A key callable also runs there and may perform waits or side effects; no asynchronous execution is implied.

Example

numbers = [3, 1, 2]
numbers.sort()
text(str(numbers))        # returns [1, 2, 3]

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.reverse

Reverse the list in place.

Syntax

list.reverse()

Parameters

None

Returns

None — No direct return value. The list order is reversed in place.

Behavior / side effects

Reverse the list in place.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [1, 2, 3]
numbers.reverse()         # numbers becomes [3, 2, 1]

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.copy

Create a shallow mutable copy of the list.

Syntax

list.copy()

Parameters

None

Returns

list — A new mutable list with the same item references.

Behavior / side effects

Create a shallow mutable copy of the list.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = [1, 2]
copied = numbers.copy()
copied.append(3)
count = len(numbers)      # returns 2

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.for_loop

Loop through items in order from left to right.

Syntax

for item in list:

Parameters

NameDescription
itemAny
Current item inside the loop.
Required · Positional or named
No default
listlist
The list to iterate.
Required · Positional or named
No default

Returns

None — No direct return value. The loop runs its body once per item.

Behavior / side effects

Loop through items in order from left to right.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

steps = range(1, 4)      # returns [1, 2, 3]
for step in steps:
    wait(step * 100)      # returns None

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

list.truthy_check

Check whether the list has at least one item.

Syntax

if list | if not list

Parameters

NameDescription
listlist
The list used in the condition.
Required · Positional or named
No default

Returns

Boolean condition — true when the list is not empty, false when it is empty.

Behavior / side effects

Check whether the list has at least one item. An empty list is treated as false.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

numbers = range(0)        # returns []
if not numbers:
    text("No items")      # returns None

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs