The code you have posted doesn't actually do any replacement. Here is a snippet that does:
for key,word in enumerate(data):
if word in unique_words:
data[key] = replacement
Here's a more compact way:
new_list = [replacement if word in unique_words else word for word in big_list]
I think unique_words
is an odd name for the variable considering its use, perhaps it should be search_list
?
Edit:
After your comment, perhaps this is better:
from collections import Counter
c = Counter(data)
only_once = [k for k,v in c.iteritems() if v == 1]
# Now replace all occurances of these words with something else
for k, v in enumerate(data):
if v in only_once:
data[k] = replacement