Method signature:
reverse()
Return value:
none
Overview:
- The reverse() method reverses the sequence of elements present in a Python deque object.
- The reverse() method returns None.
Example:
import collections
elems = (2, 6, 12, 20) dequeObject = collections.deque(elems) print("Deque object before reversal:") print(dequeObject)
retVal = dequeObject.reverse()
print("Deque object after reversal:") print(dequeObject) |
Output:
Deque object before reversal: deque([2, 6, 12, 20]) Deque object after reversal: deque([20, 12, 6, 2]) |