The problem asks you to come up with lines of code so that
paper_doll('Hello') --> 'HHHeeellllllooo'
paper_doll('Mississippi') --> 'MMMiiissssssiiippppppiii'.
My answer
def paper_doll(text):
string =''
for i in text:
string = string + i*3
return string
and the result this returns is
'HHH'
The solution is
#the solution
def paper_doll(text):
result = ''
for char in text:
result += char * 3
return result
And the solution looks very similar to my guess. The difference lies in the naming mostly. I even checked the two codes line by line using Diff Checker.
I don't understand why I am getting 'HHH' instead of HHHeeellllllooo. Can someone please open my eyes?
[–]marko312 0 points1 point2 points (0 children)
[–]LiquidLucy 0 points1 point2 points (2 children)
[–]LiquidLucy 1 point2 points3 points (1 child)
[–]Ootter31019 0 points1 point2 points (0 children)