\n (and not /n) is how you put a literal newline in strings (other than multi-line strings). Any basic tutorial should mention it. If yours didn't, you should read a different one.
Here's an alternative way to do it, assuming you have an iterable of the words (you can get it with the string and .splitlines() or .split('\n'))
- Code: Select all
>>> words = ['testa', 'testb', 'testc']
For what you have here, the .replace() method is probably better though.
Due to the reasons discussed here
we will be moving to python-forum.io
on October 1, 2016.
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.