+ 5

How can define a function that takes many arguments in python?

14th May 2018, 7:11 AM
Abdihakim Adan
Abdihakim Adan - avatar
4 Respuestas
+ 20
#U can use optional parameters... def f(*a): return sum(a) print(f(1,2,3,4,5))
14th May 2018, 9:49 AM
🌛DT🌜
🌛DT🌜 - avatar
+ 4
something like this def f(a,b,c,d,e): return a+b+c+d+e
14th May 2018, 7:14 AM
davy hermans
davy hermans - avatar
+ 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 ......
15th May 2018, 10:04 AM
Michael Yadidya
Michael Yadidya - avatar
0
Oky thanks
14th May 2018, 7:16 AM
Abdihakim Adan
Abdihakim Adan - avatar