I'm trying to write a function spread
in Python 3.6 (I cannot use any newer release), and, so far, I've got something that looks like this:
d = {"a": 1, "b": 2, "c": 3}
a, b, c = spread(d, ['a', 'b', 'c'])
a
>> 1
b
>> 2
c
>> 3
The problem is: there is kind of duplication since the position of the left side must match the keys list on the function's 2nd argument for it to make sense. So, change the order of the keys list, and variable a
will hold a different value than d['a']
. I need to keep consistency by either
a, b, c = spread(d) # how?
Or spread(d, ???)
. I'm not considering initializing a, b, c
with None
and then pass them as a list.
Any thoughts or leads on how to approach this? Is it even possible? Thanks!