code: def removeElements(self, head, val):
      """
      :type head: ListNode
      :type val: int
      :rtype: ListNode
      """
      # add a extra head for removing head
      prehead = ListNode(-1)
      prehead.next = head
      last, pos = prehead, head
      while pos is not None:
          if pos.val == val:
              last.next = pos.next
          else:
              last = pos
          pos = pos.next
      return prehead.next
  
label_desc: Use image node_id 1 for calling the Solution obj's underlying member method code with example usage: obj.removeElements(head, val) and returns: prehead