append(L, x)
|
|
|
The new list will be of the same class as L.
|
|
Only a single element can be appended with this function. To append the elements of a list, use join. To add the new element to the beginning of the list, or at a particular index, use prepend or insert, respectively.
|
|
|
Append always returns a new list, rather than modifying the input list, even if L is a MutableList.
|
|
|
Notice that the order of the arguments is switched in prepend versus append: we write prepend(x, L) and append(L, x). A good way to remember this is that the new element is visually placed before or after the list, depending on where we want it to appear in the output.
The object append is a compiled function.