Ad

Uses reduce function to sum

Code
Diff
  • from functools import reduce
    
    def sumi(a):
        return reduce(lambda x, y: x+y, a, 0)
    • from functools import reduce
    • def sumi(a):
    • t = 0
    • for n in a:
    • t += n
    • return t
    • return reduce(lambda x, y: x+y, a, 0)