- Joined
- Nov 28, 2011
- Messages
- 8,393
I'm not sure what you mean. It seems to behave the way I expected. When it gets to line 4 and s="n" it will call itself one more time with s="". That could be avoided by checking for len(s) > 1 before calling prend() again, but that duplicates the check that already has to be made in line 2 to prevent the function from doing anything if passed an empty string.
So calling prend() unnecessarily with an empty string once at the end of the string may or may not be less efficient than checking twice each time through. But it seems to work as expected.
So calling prend() unnecessarily with an empty string once at the end of the string may or may not be less efficient than checking twice each time through. But it seems to work as expected.