Skip to content

Commit b237d4a

Browse files
committed
nums为一个list,不需要判断为空就可以做join
1 parent 3b23b93 commit b237d4a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

python/06_linkedlist/singly_linked_list.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ def __repr__(self) -> str:
106106
while current:
107107
nums.append(current.data)
108108
current = current._next
109-
if len(nums) > 0:
110-
return "->".join(str(num) for num in nums)
111-
else:
112-
return ""
109+
return "->".join(str(num) for num in nums)
113110

114111
# 重写__iter__方法,方便for关键字调用打印值
115112
def __iter__(self):

0 commit comments

Comments
 (0)