craeting a method that can take any number of arguments in python

Solutions on MaxInterview for craeting a method that can take any number of arguments in python by the best coders in the world

showing results for - "craeting a method that can take any number of arguments in python"
Leni
05 May 2018
1def kwargs_iterate(**kwargs):
2    for i, k in kwargs.items():
3        print(i, '=', k)
4
5kwargs_iterate(hello='world')
6
Shea
22 Aug 2018
1def my_min(*args):
2    result = args[0]
3    for num in args:
4        if num < result:
5            result = num
6    return result
7
8my_min(4, 5, 6, 7, 2)
9
10
11
Céline
11 Jan 2019
1def combined_varargs(*args, **kwargs):
2    print(args)
3    print(kwargs)
4
5combined_varargs(1, 2, 3, a="hi")
6
Roberta
20 Jan 2016
1def my_min(*args):
2    result = args[0]
3    for num in args:
4        if num < result:
5            result = num
6    return result
7
8my_min(4, 5, 6, 7, 2)
9