I'm trying to replace the occurrence of a word with another:
word_list = { "ugh" : "disappointed"}
tmp = ['laughing ugh']
for index, data in enumerate(tmp):
for key, value in word_list.iteritems():
if key in data:
tmp[index]=data.replace(key, word_list[key])
print tmp
Whereas this works... the occurrence of ugh
in laughing
is also being replaced in the output: ladisappointeding disappointed.
How does one avoid this so that the output is laughing disappointed
?