Feb-04-2017, 11:13 PM
regex also works fine. But of the various things posted, I would prefer
", ".join(spam.split())
>>> import re >>> spam = "can you feel it coming in the air tonight" >>> re.sub(r"\s+", ", ", spam) 'can, you, feel, it, coming, in, the, air, tonight'