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