I got this list:
words = ['how', 'much', 'is[br]', 'the', 'fish[br]', 'no', 'really']
What I would like is to replace [br]
with some fantastic value similar to <br />
and thus getting a new list:
words = ['how', 'much', 'is<br />', 'the', 'fish<br />', 'no', 'really']
Advertisement
Answer
words = [w.replace('[br]', '<br />') for w in words]
This is called a list comprehension.