I am looking to do it with Python. And I don\'t want to just print it in reverse, but actually reverse the given nodes. I have seen it done in other languages but had trouble fi
def reverse(head):
# Empty list is always None
if not head:
return None
# List of length 1 is already reversed
if not head.get_next():
return head
next = head.get_next()
head.set_next(None)
rest = reverse(next)
next.set_next(head)
return rest