← Quiz: The collections Module: all 10 questions
Quiz: The collections Module · Question 5 of 10
What does this print? (code)
What does this print?
from collections import deque
d = deque([1, 2, 3], maxlen=3)
d.append(4)
print(list(d))
- A.[1, 2, 3, 4]
- B.[1, 2, 3]
- C.[2, 3, 4]
- D.An error
Answer & explanation
Correct answer: [2, 3, 4]
A full deque drops an item from the opposite end when you add.
Can you get the rest right without peeking?
Take the timed Quiz: The collections Module quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →