What is the difference between a list and a deque?

Python lists, dictionaries and sets · Freshers and experienced

Model answer

collections.deque supports O(1) appends and pops at both ends, while a list is O(n) for operations at the front. Use deque for queues. Use a list for indexed access.

Learn this topic

Dictionaries, Tuples and Sets in Python in the course Python for Beginners: Learn to Code with Real Projects.

Sign in to add your own answer.

More questions