The given problem - Given a string, return a string where for every character in the original there are three characters paper_doll('Hello') --> 'HHHeeellllllooo'
If I do this, I get the correct answer -
def paper_doll(text):
s1 = list(text)
for i in range(0,len(s1)):
s1[i] = s1[i]*3
s2 = "".join(s1)
return s2
# Check
paper_doll('Hello')
'HHHeeellllllooo'
But this doesn't work -
def paper_doll(text):
s1 = list(text)
for i in s1:
i= i*3
s2 = "".join(s1)
return s2
#Check
paper_doll('Hello')
'Hello'
Isn't i in the latter same as s1[i] in the former? What am I missing here?