+ 3

How to take unlimited number of function arguments?

--

21st Jun 2019, 7:01 AM
SudarshanPoojary
SudarshanPoojary - avatar
5 Respuestas
+ 7
def f(*args, **kwargs): print(args) print(kwargs) f(1, 2, 'a', [], a=1, b=2, c=3)
21st Jun 2019, 7:38 AM
Mert Yazıcı
Mert Yazıcı - avatar
+ 3
Which language?
21st Jun 2019, 7:28 AM
Trigger
Trigger - avatar
+ 3
def fun(**kwargs): print("kwargs") # kwargs is keyword argument in which we give multiple arguments
24th Jun 2019, 12:12 PM
anuradha mall
21st Jun 2019, 8:22 AM
SudarshanPoojary
SudarshanPoojary - avatar
+ 1
* is real gold. It also allows you to put iterables as a sequences of arguments. func(*[1, 4, 27]) = func(1, 4, 27)
21st Jun 2019, 8:47 AM
Seb TheS
Seb TheS - avatar