How do you use it? I'm guessing that you do something like yourList.insert(1)
. In your code you do: self.head = node
, where node
is what user have passed to insert
. So, on the next call to insert
you end up trying to call an int
or anything you've tried to put into the list. You need to wrap any objects given by the user with your Node
class:
def insert(self, thing):
node = Node(thing)
//...
However, please remember to post all of the relevant code, so the people trying to help you won't have to guess.
EDIT: still, after the edit the case remains the same. You don't wrap objects passed to your list, so you keep trying to call Node
methods on non-Node objects...