I want to replace an element in a list with multiple elements. So for example I have the list a = ['b', 'c']
and want to replace 'b'
with 'd', 'e'
which would give me the list a = ['d', 'e', 'c']
.
I have the following code: a = [??? if item == 'b' else item for item in a]
. How do I proceed? I would love to keep the list comprehension, as this seems to be more suitable than a.extend(('b', 'c'))
, for example.