Created
November 22, 2018 08:00
-
-
Save zhuifengshen/dc4be3427a353077df7b08bc34a1f9ea to your computer and use it in GitHub Desktop.
列表递归求和
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum(lst): | |
if lst == []: | |
return 0 | |
return lst[0] + sum(lst[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment