Construct a function that prints all elements of a Doubly Linked List in forwards and then reverse order.
DoublyLinkedList class implementation is given below.

class Node: def __init__(self, data): self.data = data self.next = None self.prev = None class DoublyLinkedList: def __init__(self): self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head if self.head is not None: self.head.prev = new_node self.head = new_node

Reset Check