'How to make a order-n callable function in python

You have the next code

def f(val):
    return lambda x: x + val

assert f(5)(6) == 11

this works, but how can you make this n-order?

assert f(5)(6)(7)...(n) == sum of values

I'm out of ideas on how to make this work.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source