Answers for "sum to number python"

16

python sum of list

>>> list = [1, 2, 3]
>>> sum(list)
6
Posted by: Guest on January-27-2020
0

sum of numbers in python

def sum_(n):
    if n == 0:
        return n
    else:
        prev_n = sum_(n - 1)
        result = prev_n + n
        return result


s = sum_(5)

print(s)

#Output:
# 15
Posted by: Guest on August-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language