From b237d4a7ade72e26b12bb0588c9a5c55daf29b1e Mon Sep 17 00:00:00 2001 From: liaozd Date: Wed, 22 May 2019 09:27:37 +0800 Subject: [PATCH] =?UTF-8?q?nums=E4=B8=BA=E4=B8=80=E4=B8=AAlist=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E9=9C=80=E8=A6=81=E5=88=A4=E6=96=AD=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E5=B0=B1=E5=8F=AF=E4=BB=A5=E5=81=9Ajoin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/06_linkedlist/singly_linked_list.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/python/06_linkedlist/singly_linked_list.py b/python/06_linkedlist/singly_linked_list.py index 2c14268..db7daa1 100644 --- a/python/06_linkedlist/singly_linked_list.py +++ b/python/06_linkedlist/singly_linked_list.py @@ -106,10 +106,7 @@ class SinglyLinkedList: while current: nums.append(current.data) current = current._next - if len(nums) > 0: - return "->".join(str(num) for num in nums) - else: - return "" + return "->".join(str(num) for num in nums) # 重写__iter__方法,方便for关键字调用打印值 def __iter__(self):