Here is my example:
sample_dict = {'foo':[1], 'bar': [2]}
{el: sample_dict[el].append(3) for el in sample_dict.keys()}
it generates:
{'foo': None, 'bar': None}
while I am expecting this:
{'foo': [1,3], 'bar': [2,3]}
What am I missing?
Here is my example:
sample_dict = {'foo':[1], 'bar': [2]}
{el: sample_dict[el].append(3) for el in sample_dict.keys()}
it generates:
{'foo': None, 'bar': None}
while I am expecting this:
{'foo': [1,3], 'bar': [2,3]}
What am I missing?
If you need to do this way:
{el: sample_dict[el]+[3] for el in sample_dict.keys()}
Generates expected output