How to print a string backwards in a new line? | Sololearn: Learn to code for FREE!

+2

How to print a string backwards in a new line?

This question is available in the Python for Intermediate course as a code project. I was supposed to solve it using recursion. I tried to solve it but it was to hard for me. I just solved it using just loops. Like this. https://code.sololearn.com/c6ISTwD9QQln/?ref=app Can you please show me how it can be solved using recursion?

1/5/2022 3:04:54 PM

Ashenafi Debella

5 Answers

New Answer

+4

def spell(txt): if txt: print(txt[-1]) return spell(txt[:-1]) txt = input() spell(txt)

+2

I hope that this code can help you https://code.sololearn.com/cv9yxzNmZI8G/?ref=app

+1

Ashenafi Debella https://www.sololearn.com/Discuss/1470297/how-to-reverse-a-string-in-python https://www.sanfoundry.com/python-program-reverse-string-using-recursion/ https://www.geeksforgeeks.org/reverse-a-string-using-recursion/amp/ https://www.geeksforgeeks.org/reverse-string-python-5-different-ways/amp/ https://stackoverflow.com/questions/5532902/python-reversing-a-string-using-recursion

+1

Thanks everyone

0

Let's say d = "toffee" print(d[::-1])