+ 2

Whats wrong with my code please?

I ve just written the recursive function to reverse string but in solo it gives me no output ; Here is my code def spell(txt): if len(txt) == 0: return txt else: return spell(txt[1:]) + txt[0] txt = "hello" print(spell(txt)) #here try to output #o #l and so on for l in txt: print(l) print(spell(l))

6th Feb 2021, 3:11 PM
ÄKoderj
4 ответов
+ 7
it could also be done in this way: text ="hello" print("\n".join([char for char in text[::-1]]))
6th Feb 2021, 4:32 PM
Lothar
Lothar - avatar
+ 4
Last line print(spell(txt))
6th Feb 2021, 3:18 PM
Oma Falk
Oma Falk - avatar
+ 1
Dear Teacher I do change it many times,but it doesnt work
6th Feb 2021, 3:31 PM
ÄKoderj
6th Feb 2021, 3:32 PM
Oma Falk
Oma Falk - avatar