Answers for "recursively count string"


recursively count string

def length(s): 
   if not s:  # test if there are no more characters in the string
      return 0
   else:  # maintain a count by adding 1 each time you return
          # get all but the first character using a slice
      return 1 + length( s[1:] )
Posted by: Guest on September-11-2020

Code answers related to "recursively count string"

Python Answers by Framework

Browse Popular Code Answers by Language