I need a recursive function that returns the string that it receives as a parameter inverted , I got this function:
def stringinvert(palavra):
if palavra < 10:
print(palavra)
return stringinvert(palavra[::-1])
print(stringinvert('teste'))
But it generates an error that in this case is this:
if palavra < 10:
TypeError: '<' not supported between instances of 'str' and 'int'
Well, that was foreseeable for me. The question is: the recursive step is the string having only one letter, ie I return only this letter, the problem is how will I create this condition in Python?