mirror moves the last letter of a text to the front and the first letter to the back, and does the same to the letters between them by calling itself.
def mirror(s):
if len(s) <= 1:
return s
return s[-1] + mirror(s[1:-1]) + s[0]
print(mirror("stream"))
What does the program print?Log in to join the discussion.
Loading…