I'm just starting out with Python and need some help. I have the following list of dictionaries that contain a list:
>>> series
[{'data': [2, 4, 6, 8], 'name': 'abc'}, {'data': [5, 6, 7, 8], 'name': 'efg'}]
>>>
How can I multiply each elements of inner lists by a constant without using loops and do it in place.
So if I have:
>>> x = 100
The code should result in:
>>> series
[{'data': [200, 400, 600, 800], 'name': 'abc'}, {'data': [500, 600, 700, 800], 'name': 'efg'}]
The best I could come up with my limited knowledge is this (and I don't even know what "[:]" is):
>>> for s in series:
... s['data'][:] = [j*x for j in s['data']]
...
>>>
How can I remove the for loop?
An explanation of the code or a pointer to docs would also be nice.
Thanks!