【发布时间】:2020-10-08 13:39:54
【问题描述】:
我无法正确加入字符串。
代码如下:
def mub(s):
count = 1
for i in range(len(s)):
words = s[i] * count
list_of = list(words)
print('-'.join(list_of),end='')
count+=1
mub('Abcd')
它给了我这个作为输出: ab-bc-c-cd-d-d-d
但我想要的输出是这样的: a-bb-ccc-dddd
我认为错误是在for循环之后。
【问题讨论】:
标签: python-3.x string list