From d7d7e6c733716a7eb516dea3c8b7660e8d0ac9ce Mon Sep 17 00:00:00 2001 From: ray Date: Sat, 1 Apr 2023 20:54:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=200203.=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E9=93=BE=E8=A1=A8=E5=85=83=E7=B4=A0.md=20=E5=86=99=E6=B3=95?= =?UTF-8?q?=E6=9B=B4Python=E4=B8=80=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0203.移除链表元素.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/0203.移除链表元素.md b/problems/0203.移除链表元素.md index 7e3955a5..b52f16ea 100644 --- a/problems/0203.移除链表元素.md +++ b/problems/0203.移除链表元素.md @@ -316,8 +316,8 @@ class Solution: def removeElements(self, head: ListNode, val: int) -> ListNode: dummy_head = ListNode(next=head) #添加一个虚拟节点 cur = dummy_head - while(cur.next!=None): - if(cur.next.val == val): + while cur.next: + if cur.next.val == val: cur.next = cur.next.next #删除cur.next节点 else: cur = cur.next