From 1a8b4f63640e157d577a560371cb61685280b141 Mon Sep 17 00:00:00 2001 From: Rui <58332748+wodray@users.noreply.github.com> Date: Tue, 21 Jan 2025 18:46:41 +0800 Subject: [PATCH] Update linkedlist_deque.py (#1625) According to PEP 8, "Comparisons to singletons like None should always be done with is or is not, never the equality operators." --- codes/python/chapter_stack_and_queue/linkedlist_deque.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codes/python/chapter_stack_and_queue/linkedlist_deque.py b/codes/python/chapter_stack_and_queue/linkedlist_deque.py index 0a39c95c8..29aa0dfa1 100644 --- a/codes/python/chapter_stack_and_queue/linkedlist_deque.py +++ b/codes/python/chapter_stack_and_queue/linkedlist_deque.py @@ -69,7 +69,7 @@ class LinkedListDeque: val: int = self._front.val # 暂存头节点值 # 删除头节点 fnext: ListNode | None = self._front.next - if fnext != None: + if fnext is not None: fnext.prev = None self._front.next = None self._front = fnext # 更新头节点 @@ -78,7 +78,7 @@ class LinkedListDeque: val: int = self._rear.val # 暂存尾节点值 # 删除尾节点 rprev: ListNode | None = self._rear.prev - if rprev != None: + if rprev is not None: rprev.next = None self._rear.prev = None self._rear = rprev # 更新尾节点