The main reason your code is not working may be your return function. If you want to repeat char in string please use this code:
allin = ''
for character in str:
allin = allin + char + char
If you dont want to use loops you can use:
return ''.join([c+c for c in str])
I hope this may help you the most. If you still do not understand please fell free to ask me anything you want to know about this thing.