Collection Methods
collections.deque.appendleft()
Append at the left end, discarding the rightmost item if a bounded deque is full.
Formal Syntax & Structure
python syntaxpython
deque_instance.appendleft(x, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | object | Value to append, remove, search for or insert. |
Return Value
None
No return value; the operation changes the receiver in place.
Working Example
Example Snippetpython
import collectionsd=collections.deque([1,2],maxlen=2)d.appendleft(3)print(list(d))