educative.io

Self.len_recursive(node.next), is self an object or is it a constructor?


Type your question above this line.

Course: https://www.educative.io/collection/10370001/5474278013140992
Lesson: https://www.educative.io/collection/page/10370001/5474278013140992/6027213679886336

Hello @Mohammad_Alim,

self in Python represents an instance of a class. It allows us to access the attributes and methods of a class. In this particular example, self.len_recursive(node.next) means that we are calling the method len_recursive of the LinkedList class and we are passing node.next to it as the argument. Hope this clears your confusion. Feel free to reach out if you have any more queries.