📜  递归计算字符串 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:22.868000             🧑  作者: Mango

代码示例1
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:] )