73.9k views
1 vote
A deque is a type of collection, but it’s not automatically available when you open IDLE. What is missing that allows you to use the deque class?

User Saskia
by
4.2k points

1 Answer

2 votes

Answer:

In order to use the 'deque' class, you will need to import it from the collections module. You can do this by adding the following line at the beginning of your code:

from collections import deque

This will allow you to create deque objects and use their methods.

For example:

from collections import deque

my_deque = deque()

my_deque.append(1)

my_deque.appendleft(2)

print(my_deque) # prints deque([2, 1])

Step-by-step explanation:

User Yanti
by
3.5k points