1def length(s):
2 if not s: # test if there are no more characters in the string
3 return 0
4 else: # maintain a count by adding 1 each time you return
5 # get all but the first character using a slice
6 return 1 + length( s[1:] )