Linked Lists- Move the Tail to the Head
Code:
def move_tail_to_head(self):
last = self.head
second_to_last = None
while last.next:
second_to_last = last
last = last.next
last.next = self.head
second_to_last.next = None
self.head = last