I would like to create a function of n variables in python, such as
n=3
def func(n1,n2,n3):
return sum(n1+n2+n3)
func(1,2,3) = 6
func(3,3,3)=9
or if n=4,
n=4
def func(n1,n2,n3,n4):
return sum(n1+n2+n3+n4)
func(1,2,3,4) = 10
There is a perfect example of someone doing this in julia: How to create a function of n variables (Julia)
using this solution
function f(x...)
sum(x)
end
julia> f(1,2,3)
6
However I do not know how to translate the ellipses type input to python