2021年1月29日星期五

Writing a function using (**kwargs) then summing

I want to define a function. This function should be able to accept variable number of keyword arguments of not predefined names. Then the function returns the number of keyword arguments.

For example:

result = all_the_kwargs(my_kwarg = "random", second_kwarg = "more", some_number = 1)    print(result)  # should print the number 3  

I don't understand how I can count the number of keyword arguments with heterogeneous values (integers and strings mixed).

https://stackoverflow.com/questions/65964126/writing-a-function-using-kwargs-then-summing January 30, 2021 at 10:41AM

没有评论:

发表评论