+ 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))
4 odpowiedzi
+ 7
it could also be done in this way:
text ="hello"
print("\n".join([char for char in text[::-1]]))
+ 4
Last line print(spell(txt))
+ 1
Dear Teacher I do change it many times,but it doesnt work