I got a .txt file, where the line is a sequence of names in a row:
John Marry Joseph
And I need to extend each of them with @company.com, to get this result:
Is there a way how to write it with regex or some other method?
KISS
[(y+"@company.com") for y in x.split()]
If you don't want a list then you can join
it, like this
print(' '.join([(y+"@company.com") for y in x.split()]))
or this
print('@company.com '.join(x.split()) + '@company.com')
Using regex re.sub
x = "John Marry Joseph"
print(re.sub("([^\s]+)", "\\[email protected]", x))