class Solution:
    def deleteNode(self , head: ListNode, val: int) -> ListNode:
        # write code here
        
        # 极端情况
        if not head: return None
        if head.val==val: return head.next

        current=head
        prev=None
        while current:
            if current.val==val:
                current=prev
                current.next=current.next.next
                break
            prev=current
            current=current.next
        return head