Dumping queue into list or array in Python
Prerequisite: Queue in Python
Here given a queue and our task is to dump the queue into list or array. We are to see two methods to achieve the objective of our solution.
In this example, we will create a queue using the collection package and then cast it into the list
Initial queue deque(['a', 'b', 'c']) <class 'collections.deque'>
Let’s create a list and cast into it:
Convert into the list ['a', 'b', 'c'] <class 'list'>
In this example, we will create a queue using the queue module and then cast it into the list.
Initial queue deque([1, 2, 3, 4, 5]) Converted into the list [1, 2, 3, 4, 5]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course