I am trying to create a deque of strings, but when I add a string to the deque it always breaks the string up into individual characters. Here is my code so far:
from collections import deque
my_string = "test"
my_queue = deque(my_string)
print my_queue
The output I get is:
deque(['t', 'e', 's', 't'])
I would like the output to be:
deque(['test'])
Any thoughts?
The deque constructor takes an iterable as a parameter, if you just give the string to it, it will interpret it as a sequence of characters.
In order to do what you want you should wrap your string into a list:
Of course you can do everything in one step: