Is there any way to remove an item in deque by index?
dq = deque(['a','b','c'])
dq.removeByIndex(1)
#output deque(['b', 'c'])
I only see remove by value in the doc. Also, I know I can just pop it i
times and then put it back, but it doesn't look pretty.
You can try this :
from collections import deque
deq = deque([1, 2, 3, 4])
del deq[1]
print(deq)
Output:
deque([1, 3, 4])