First of all, your function ends at the first
return call, so the join() method never gets called!
Next, you need to capture the result of doing
ans.join(new) : as a method join() does not change anything but it returns the string. Try something like
newText = ans.join(new) or even
return ans.join(new) which saves a step.
I also noticed there is some funny looping going on: although you are using
n to loop through
d , you don't seem to be using it. You could just be adding each character to the front of what you already have, something like
for n in d:
new = [n] + new
Hope that helps