text: # Remove all elements from a linked list of integers that have value val.
  #
  # Example:
  #
  #
  # Input:  1->2->6->3->4->5->6, val = 6
  # Output: 1->2->3->4->5
  #
  #
  
  
  # Definition for singly-linked list.
  # class ListNode:
  #     def __init__(self, x):
  #         self.val = x
  #         self.next = None
  
  class Solution:
      def removeElements(self, head, val):
          """
          :type head: ListNode
          :type val: int
          :rtype: ListNode
          """
          if head is None:
              return head
          
          fakeHead = ListNode(0)
          fakeHead.next = head
          cur = fakeHead
          
          while cur.next:
              if cur.next.val is val:
                  cur.next = cur.next.next
              else:
                  cur = cur.next
  
          return fakeHead.next
  