Method Signature
remove(value)
Return value
Returns the removed element.
Method Overview
- The remove() method removes the first occurrence of the value from a deque as specified the value parameter.
- If the deque object does not have any element with the specified value, remove() raises an exception of type ValueError.
Example
import collections
tokens = ("I", "chatter", "chatter", "as", "I", "flow")
poetryDeque = collections.deque(tokens)
removeValue = "chatter"
print("Deque entries before remove():")
print(poetryDeque)
poetryDeque.remove(removeValue)
print("Deque entries after removing the entry:%s"%(removeValue))
print(poetryDeque)Output
Deque entries before remove():
deque(['I', 'chatter', 'chatter', 'as', 'I', 'flow'])
Deque entries after removing the entry:chatter
deque(['I', 'chatter', 'as', 'I', 'flow'])