标签: python python-3.x
paper_doll('Hello')->'HHHeeellllllooo'
paper_doll('Hello')
paper_doll('Mississippi')->'MMMiiisssssiiippppppiii'
paper_doll('Mississippi')
答案 0 :(得分:3)
您可以走老式路线,并通过遍历原始字符串来构建新字符串:
def paper_doll(astr): newstr = "" for char in astr: newstr += char*3 return newstr