push_front
Builtin index · Collections & strings
push_back(l, x)
Input: l, x · Output: no output
What it is
l is a linked_list handle; x is any value. Grows l at the back (push_back) or front (push_front) in O(1).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
push_back(l, x) | l —l is a linked_list handle.x —x is any value. | no output | — |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
l = linked_list()
l.push_back(1)
l.push_back(2)
l.push_front(0)
print(l.to_vec()) # (0, 1, 2)
print(pop_front(l)) # 0 -- removes from the front
print(pop_back(l)) # 2 -- removes from the back
print(l.to_vec()) # (1) -- what's left
output
(0, 1, 2) 0 2 (1)
from collections-strings
How it works
linked_list() (§ data structures pass, 2026-09-01, that module's own doc comment for why VecDeque rather than a real boxed-node chain.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.
See also
push_back — documented in the same entry.