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