Didn't understand the output of the following Python 3 code with reduce function?

Shivlal Sharma sshivlal9601 at gmail.com
Fri Aug 28 10:06:22 EDT 2020


I have seen this code on one of competative programming site but I didn't get it, Why output is 9?

from functools import *

def ADDS(a,b):
    return a+1
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]
add = reduce(ADDS, nums)
print(add)

output: 9


More information about the Python-list mailing list