What is the output of the following Python code snippet?
from collections import deque
d = deque([1, 2, 3])
d.rotate(1)
print(d)
-
A
deque([1, 2, 3])
-
B
deque([3, 1, 2])
Correct answer
-
C
[3, 1, 2]
-
D
deque([2, 3, 1])
Correct answer
B. deque([3, 1, 2])
6 views
Explanation
rotate(1) moves the rightmost element to the left end.
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ