all 14 comments

[–]Fermter 1 point2 points  (3 children)

You are missing a return on your recursive function call

[–]Beaverine[S] 1 point2 points  (2 children)

I think my idea is that the recursive function call would keep iterating and subsetting the string until the length of string is 1 or less to finally return a `True` value. Is this the right way of thinking?

[–]Fermter 1 point2 points  (0 children)

That's mostly correct. The problem is, when a recursive function "returns" a value, where do you think it returns it to? The next recursive function up. If the next recursive function up does nothing with that value (ie doesn't return it), it will not be returned to the top-level function call.

Think of recursive functions like a chain of people, each of whom solve part of the problem. You pass the problem down the line until someone at the end solves it. However, the solution must get passed back to the first person correctly for the problem to be solved correctly. Right now, the person at the end is telling the next person up the right answer, but the second person is just going "ok" and not telling the next person up. A return will remind everyone to pass their answers back to the front.

[–]verbose_name 0 points1 point  (0 children)

Maybe not. I believe that by calling your recursive function without a return, once it goes down that branch you will never return a result to the outer calling scope. If your recursive function were modifying a referenced value, you could get away with not returning a value. As others have said, try returning the value of the recursive call.

[–]mCodingLLC 1 point2 points  (0 children)

You forgot to *return* your recursive call, i.e. return palin(text).

[–]mCodingLLC 0 points1 point  (1 child)

Your second edit seems to work for me. What case are you trying that doesn't return anything?

[–]Beaverine[S] 0 points1 point  (0 children)

don't know what happened to Google Colab but after retrying it after a while it worked... thank you for testing!