From c773d041402115bff61790ed0c4be2fd36193359 Mon Sep 17 00:00:00 2001 From: bjweimengshu Date: Thu, 19 Nov 2020 10:26:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=BE=E8=A1=A8=E5=88=A0=E9=99=A4=E5=A4=B4?= =?UTF-8?q?=E7=BB=93=E7=82=B9=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BB=85?= =?UTF-8?q?=E6=9C=89=E4=B8=80=E4=B8=AA=E7=BB=93=E7=82=B9=EF=BC=8C=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E6=8A=8A=E5=B0=BE=E7=BB=93=E7=82=B9=E7=BD=AE=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chapter2/part2/MyLinkedList.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/chapter2/part2/MyLinkedList.py b/src/chapter2/part2/MyLinkedList.py index a0d2fe4..1bbffb7 100644 --- a/src/chapter2/part2/MyLinkedList.py +++ b/src/chapter2/part2/MyLinkedList.py @@ -49,6 +49,8 @@ def remove(self, index): # 删除头节点 removed_node = self.head self.head = self.head.next + if self.size == 1: + self.last == Node elif index == self.size - 1: # 删除尾节点 prev_node = self.get(index-1)