+ 5
How can define a function that takes many arguments in python?
4 Respuestas
+ 20
#U can use optional parameters...
def f(*a):
return sum(a)
print(f(1,2,3,4,5))
+ 4
something like this
def f(a,b,c,d,e):
return a+b+c+d+e
+ 3
def some_func(*args , **kwargs):
return something
specifying args and kwargs will allow you to specify as many arguments you like .....
args stand for arguments
kwargs stand for keyword argument
NOTE: It doesn't matter whether you specify args and kwargs (*,**) in front of them is what python looks for .....
check out python docs for more detailed explanation ......
0
Oky thanks