Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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:] )
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #recursively #count #string
ADD COMMENT
Topic
Name
4+9 =