[Solved] Why isn’t length(self.next) a valid expression in python? [closed]


What is length? length does not exist, but Node.length does.

The reason return(1+length(self.next)) doesn’t work is because you’re calling length(), not Node.length().

Instead, try this:

return(1+LinkedList.length(self.next))

Or this (my preference):

return(1+self.next.length())

solved Why isn’t length(self.next) a valid expression in python? [closed]