---
id: 6888d05ba074461b64f8eaca
title: Step 16
challengeType: 20
dashedName: step-16
---

# --description--

Next, you're going to create another method that will be used to remove a given element from the linked list.

Create a method called `remove` with two parameters, `self` and `element`. Inside it, create a variable called `previous_node` and assign `None` to it.

# --hints--

You should create a method called `remove`.

```js
({
  test: () => assert(
    runPython(`
      _Node(_code).find_class("LinkedList").has_function("remove")
    `)
  )
})
```

Your `remove` method should have two parameters, `self` and `element`.

```js
({ 
    test: () => runPython(`assert _Node(_code).find_class("LinkedList").find_function("remove").has_args("self, element")`) 
})
```

You should assign `None` to `previous_node` in the `remove` method.

```js
({
  test: () =>
    assert(
      runPython(
        `_Node(_code).find_class("LinkedList").find_function("remove").find_body().is_equivalent("previous_node = None")`
      )
    )
})
```

# --seed--

## --seed-contents--

```py
class LinkedList:
    class Node:
        def __init__(self, element):
            self.element = element
            self.next = None
            
    def __init__(self):
        self.length = 0
        self.head = None

    def is_empty(self):
        return self.length == 0
    
    def add(self, element):
        node = self.Node(element)
        if self.is_empty():
            self.head = node
        else:
            current_node = self.head
            while current_node.next is not None:
                current_node = current_node.next
            current_node.next = node
        self.length += 1

--fcc-editable-region--
    
--fcc-editable-region--

my_list = LinkedList()
print(my_list.is_empty())

my_list.add(1)
my_list.add(2)
print(my_list.is_empty())
print(my_list.length)
```
