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