Data Structures, Algorithms, Data Engineering, Data Science, Doubly Linked List.
self.head count = 0 node1 = None node2 = None while current: if count == index1: node1 = current if count == index2: node2 = current current = current.next count += 1 if node1 and node2: node1.data, node2.data = node2.data, node1.data Execution: dllist.insert(5) dllist.insert(6) dllist.swap(1, 3)