Skip to content

Missing last = n in LinkedList remove method #2

Description

@rodrigo-albuquerque
def remove(self, value):
    n = self.head
    last = None
    while n != None:
        if n.value == value:
            if last == None:
                self.head = self.head.next
            else:
                last.next = n.next
            return True
        last = n  **<-- This is missing**
        n = n.next
    return False

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions