Collection Methods
collections.deque.rotate()
Move items cyclically to the right for positive n, left for negative n. Length and bound stay unchanged.
Formal Syntax & Structure
python syntaxpython
deque_instance.rotate(n=1, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| n | int | Signed number of positions; positive rotates right, negative left. |
Return Value
None
No return value; the operation changes the receiver in place.
Working Example
Example Snippetpython
import collectionsd=collections.deque([1,2,3])d.rotate(1)print(list(d))