Spelling Backwards | Sololearn: Learn to code for FREE!


Spelling Backwards

I need help on the spelling backwards challenge.

4/1/2022 3:55:40 PM

Ilyas Guissous

7 Answers

New Answer


def spell(txt): #your code goes here if txt=="": return else: print(txt[-1]) return spell(txt[:-1]) txt = input() spell(txt)


Language?? And what to do? (elaborate it)


Ilyas Guissous , please also put your code in playground, save it and post the link to this file here. thanks!


it seems to be the *intermediate python* tutorial exercise 19. the task description is: Given a string as input, use recursion to output each letter of the strings in reverse order, on a new line. Sample Input HELLO Sample Output O L L E H Complete the recursive spell() function to produce the expected result


Beh , your codes are not both absolutely correct, since the first one outputs the string in one line. but following the task description this task should be done with a recursive function.


Use [::-1] Example: Str = str(input()) print(Str[::-1]) ******************************* There is another way: Str = str(input()) List = list(Str) List_reverse = List[::-1] for i in List_reverse: print(i)