Source Code:
(back to article)
from functools import reduce def add(x, y): return x + y numbers = [10, 20, 30, 40, 50] total = reduce(add, numbers) print("The sum of", numbers, "is", total)
Result:
Report an issue