educative.io

Educative

Intro to Linked Lists - Insertions at tail

Hello,
I was not able to make the solution work. It gave me an error saying that insertAtTail is not defined!

However, when I redefined the method as insertAtTail(self, list, value) and used list.insertAtTail(list, 3), it worked!

Did I do something wrong, or is there an error in the given solution?

Thoughts?
Thank you!
Sincerely,
Rohit

There is no error in the solution. The method is outside the class. If we declare the method within the class, then you have to write self. We have initiated the list object and then passed the list and the value to the insert_at_tail function as an argument.

Happy Learning! :slight_smile:
Anum Hassan | Developer Advocate
educative.io