Code Explanation:
Import deque:
from collections import deque allows you to use the deque class.
Initialize deque:
dq = deque([1, 2, 3]) creates a deque containing [1, 2, 3].
Append to deque:
dq.append(4) adds the number 4 to the right end of the deque.
Now the deque becomes [1, 2, 3, 4].
Print deque:
print(dq) will output:
deque([1, 2, 3, 4])
.png)

0 Comments:
Post a Comment