I have a list of tokens. Some start with an @ sign. I want to change all those strings to a generic @user. I have tried this:
>>> words = ['@john', 'nina', 'michael', '@bebeto']
>>> words = [w.replace(w, '@user') for w in words if w.startswith('@')]
>>> words
['@user', '@user']
>>>
What am I getting wrong here?
['@user', 'nina', 'michael', '@user']