I'm trying to make a recursion sequence (Have to do it like this) where I print a * followed by the last character plus the following character on the next line, etc. So if "Hello" was passed, it would print:
*
o
ol
oll
olle
olleH
My question is, how do I get the last character to stay and how do I get the star to print first. I have it so everything prints in reverse, but only one character and the star prints last. This is what I have:
def reverse(s):
if len(s) == 0:
return ('*')
else:
print(s[-1])
return reverse(s[0:-1])
Thanks!