mirror of
https://github.com/krahets/hello-algo.git
synced 2025-01-23 06:00:27 +08:00
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."
This commit is contained in:
parent
9c78c513c2
commit
1a8b4f6364
@ -69,7 +69,7 @@ class LinkedListDeque:
|
|||||||
val: int = self._front.val # 暂存头节点值
|
val: int = self._front.val # 暂存头节点值
|
||||||
# 删除头节点
|
# 删除头节点
|
||||||
fnext: ListNode | None = self._front.next
|
fnext: ListNode | None = self._front.next
|
||||||
if fnext != None:
|
if fnext is not None:
|
||||||
fnext.prev = None
|
fnext.prev = None
|
||||||
self._front.next = None
|
self._front.next = None
|
||||||
self._front = fnext # 更新头节点
|
self._front = fnext # 更新头节点
|
||||||
@ -78,7 +78,7 @@ class LinkedListDeque:
|
|||||||
val: int = self._rear.val # 暂存尾节点值
|
val: int = self._rear.val # 暂存尾节点值
|
||||||
# 删除尾节点
|
# 删除尾节点
|
||||||
rprev: ListNode | None = self._rear.prev
|
rprev: ListNode | None = self._rear.prev
|
||||||
if rprev != None:
|
if rprev is not None:
|
||||||
rprev.next = None
|
rprev.next = None
|
||||||
self._rear.prev = None
|
self._rear.prev = None
|
||||||
self._rear = rprev # 更新尾节点
|
self._rear = rprev # 更新尾节点
|
||||||
|
Loading…
Reference in New Issue
Block a user