Implementing a delete node by index value for singly linked list

In the delete method:

(1) Change:

if self.headval ==index:

to:

if index == 0:

(2) And change:

if n.nextval.dataval==index:

…to:

index -= 1
if index == 0:

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top