Imagine we have a dictionary
views_params = {"list_a": [1,2,3], "list_b": [1,2,8]}
I do want to iterate in each list of values by key using the following function:
def function_with_listed_arguments(k, y, z):
w = k + y + 2*z
return w
I tried using a dictionary comprehension to get key:value pairs:
dictionary_list = {
k: function_with_listed_arguments(v) for k,v in views_params
}
final_result = [dictionary_list.values()]
print(final_result)
The final result should be [9,19]
However, I am getting ValueError: too many values to unpack (expected 2)
in the dictionary comprehension. Anybody can point me to what am I doing wrong?
Tried with **kwargs
still no results.