# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def deleteNode(self, head: ListNode, val: int) -> ListNode:
dummy = ListNode(-1)
dummy.next = head
pre = dummy
while pre.next:
if pre.next.val == val:
pre.next = pre.next.next
break
pre = pre.next
return dummy.next