I have one list like this:
>>> a = ['1G', '1G', '1G', '1G', '10G', '10G', '10G', '10G', '25G', '25G', '25G', '25G']
Here are the indexes of the elements which I want to change in list a
:
>>> ind = [4, 8]
I want to change 4th and 8th index elements with following:
>>> mode = ['40G', '100G']
I tried this:
>>> for i, m in zip(ind, mode):
... a[i] = m
With this, I am able to update 4th and 8th index elements in list a
:
>>> a
['1G', '1G', '1G', '1G', '40G', '10G', '10G', '10G', '100G', '25G', '25G', '25G']
I want to delete 3 elements after 4th index (i.e. 5, 6, 7) and 3 elements after 8th index (i.e. 9, 10, 11) from a
, I am not able to delete them in one shot. Can someone please help me with this problem?
>>> for i, m in zip(ind, mode):
... del a[i+1:i+4]
...
But after this I loose index