Nov-21-2020, 07:30 PM
It would help to have the entire error message (especially including line numbers).
Your listprint() is a bit off...
But then you ask for
I'm not sure why you're checking the val if it's None. Normally I would expect every node to have a particular value, and the
Your listprint() is a bit off...
def listprint(self): printval = self.val while printval is not None: print (printval.val) printval = printval.nextI believe
self
is supposed to be a node. So self.val (which you assign to printval
) is an integer. But then you ask for
printval.val
. That would be the same thing as self.val.val
and isn't right. I'm not sure why you're checking the val if it's None. Normally I would expect every node to have a particular value, and the
.next
attribute might be None (but not the val).