There's a difference in Python between "keyword arguments", "optional arguments" and "positional arguments".
An example of a function using them is (from python doc) :
sorted(iterable, *, key=None, reverse=False)
Here the argument iterable
is a positional argument, meaning that you just have to give your iterable to the function: it would be something like sorted(my_list)
. These arguments are mandatory.
The other parameters are called keyword arguments because they can be specified using the keyword. You can give only one of them if you'd like. If you don't specify the keyword, the order of arguments is the one given in the definition.
For instance if you want to sort a list in the reverse order, you'd write: sorted(my_list, reverse=True)
. Writing sorted(my_list, True)
would not give you a list sorted in the reverse order.
Coming back to your example, your function accepts two positional parameters and an optional one (the optional one is not a keyword argument though). So you just need to write:
reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])
.
PS: all positional arguments must be specified before using keyword arguments, otherwise it raises an error