title: How do I remove node in Linked List?
body: <p>I am implementing Linked List by using Python. Here is my code</p>
  
  <pre class="lang-py prettyprint-override"><code>class Node:
      def __init__(self, value):
          self.value = value
          self.next = None
  
  class LinkedList:
      def __init__(self, head = None):
          self.head = head
  
      def append(self, newElement):
          current = self.head
          if self.head:
              while current.next:
                  current = current.next
              current.next = newElement
          else:
              self.head = newElement
      #get position time complexity O(n)
      #get the node at a specific position
      def get_position(self, position):
          current = self.head
          current_pos = 1
          while current_pos &lt;= position:
              if current_pos == position:
                  return current
              current = current.next
              current_pos += 1
          return None
      #Insert element
      # Time complexity O(n)
      def insert_element(self, element, position):
          if position &gt; 1:
              front_pos = self.get_position(position - 1)
              end_pos = self.get_position(position + 1)
              front_pos.next = element
              element.next = end_pos
          else:
              element.next = self.head
              self.head = element
      def delete_element(self, element):
          current = self.head
          previous = None
          while current:
              if current.value == element:
                  if not previous:
                      self.head = element
                  previous.next = current.next
  
              else:
                  current = current.next
                  previous = current
  
          else:
              return False
  
  
  node1 = Node("Iron Man")
  node2 = Node("Capitain America")
  node3 = Node("Doctor Strange")
  node4 = Node("Spider man")
  node5 = Node("Rieder")
  print("Node1 Value is {}".format(node1.value))
  print("Node1 next Value is {}".format(node1.next))
  print("Node2 Value is {}".format(node2.value))
  print("Node2 next Value is {}".format(node2.next))
  Avengers = LinkedList()
  Avengers.append(node1)
  print("Firt element in link list is {}".format(Avengers.head.value))
  Avengers.append(node2)
  print("After Iron Man is {}".format(Avengers.head.next.value))
  print(Avengers.get_position(2).value)
  Avengers.append(node3)
  Avengers.append(node4)
  Avengers.insert_element(node5, 4)
  print(Avengers.get_position(4).value)
  Avengers.delete_element(node5)
  print(Avengers.get_position(4).value)
  </code></pre>
  
  <p>Here is my output:</p>
  
  <pre><code>Node1 Value is Iron Man
  Node1 next Value is None
  Node2 Value is Capitain America
  Node2 next Value is None
  Firt element in link list is Iron Man
  After Iron Man is Capitain America
  Capitain America
  Rieder
  Rieder
  </code></pre>
  
  <p>The list structure link like this: Ironman -> Capitain America -> Doctor Strange -> Rieder -> Spiderman</p>
  
  <p>Therefore, if I do not want the "Rieder" node. The last line of output should show "Spider man"</p>
  
  <p>What happened in my code? Really appreciate for people who help me out :D</p>