class Node:
    """Node class for linked list"""

    def __init__(self, data, next=None):
        self.data = data
        self.next = next

class LinkedList:
    """LinkedList class"""

    def __init__(self, head=None):
        self.head = head

    def reverse(self):
        """Reverse the list in place"""
 
        def _reverse(curr, prev):
            if not curr:
                return prev
            next = curr.next
            curr.next = prev
            prev = curr
            curr = next
            return _reverse(curr, prev)
 
        # update the head of the original linked list 
        self.head = _reverse(curr=self.head, prev=None)
        
        
if __name__=="__main__":
    link=LinkedList()
    link.reverse()
