Why in recursive function 1 is added to list cutout [1:]

前端 未结 0 428
悲&欢浪女
悲&欢浪女 2020-11-29 15:46

I have a function:

def sum(list):
if list == []:
    return 0
return 1 + sum(list[1:])

And I couldn\'t find anywhere a normal explanation of

相关标签:
回答
  • 消灭零回复
提交回复
热议问题