def removeElements(self, head, val):
    '\n        :type head: ListNode\n        :type val: int\n        :rtype: ListNode\n        '
    while head:
        if (head.val == val):
            head = head.next
        else:
            break
    if (not head):
        return head
    cur = head
    pre = cur
    while cur:
        if (cur.val != val):
            pre = cur
            cur = cur.next
        else:
            cur = cur.next
            pre.next = cur
    return head
:type head: ListNode
:type val: int
:rtype: ListNode
def removeElements(self, head, val):
    '\n        :type head: ListNode\n        :type val: int\n        :rtype: ListNode\n        '
    while head:
        if (head.val == val):
            head = head.next
        else:
            break
    if (not head):
        return head
    cur = head
    pre = cur
    while cur:
        if (cur.val != val):
            pre = cur
            cur = cur.next
        else:
            cur = cur.next
            pre.next = cur
    return head