I'm blanking out trying to write a simple function to count the string length recursively.
I can do sums, fibonacci, and factorial easy but I'm trying to create the simplest function with only one parameter, I don't like having a second just as a counter index..
Can any post something small for me?
Is this what you are looking for?
def recursiveLength(theString):
if theString == '': return 0
return 1 + recursiveLength(theString[1:])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With