(Python) Help in modfiying a string from the clipboard
<p>Basically I'm copying a bunch of lists from <a href="https://en.wikipedia.org/wiki/List_of_lists_of_lists" rel="nofollow">https://en.wikipedia.org/wiki/List_of_lists_of_lists</a> into my clipboard.
When I run my program, it will add bullets after and before each line.</p>

<p>For example: </p>

<pre><code>Lists of Iranian films
</code></pre>

<p>Would convert into:</p>

<pre><code>â¢â¢ Lists of Iranian films â¢â¢
</code></pre>

<p>And so forth. The program works when I add bullets before the line but when I put them after it it just prints one long string without any newline characters. Can anyone tell me what am I doing wrong?</p>

<p>Here's the code:</p>

<pre><code>#bulletPointAdder.py   - Adds Wikipedia bullet points to the start and end
#of each line of text on the clipboard

import pyperclip
text=pyperclip.paste()      #paste a big string of text from clipboard into the 'text' string


# Separate lines and add stars
lines = text.split('\n')     #'lines' contains a list of all the individual lines up until '\n'
                             #lines= ['list of iserael films', 'list of italian films' ...]

for i in range(len(lines)):         #loop through all indexes in the "lines" list
    lines[i] = 'â¢â¢' + lines[i] + 'â¢â¢'   #add bullets before and after each line

text = '\n'.join(lines)         #put a '\n' in  between the list members (joins them) into a single string
pyperclip.copy(text)
</code></pre>

<p>In my clipboard:</p>

<pre><code>List of Israeli films before 1960
List of Israeli films of the 1960s
List of Israeli films of the 1970s
List of Israeli films of the 1980s
</code></pre>

<p>Clipboard pasted in Notepad:</p>

<pre><code>â¢â¢List of Israeli films before 1960â¢â¢â¢â¢List of Israeli films of the 1960sâ¢â¢â¢â¢List of Israeli films of the 1970sâ¢â¢â¢â¢List of Israeli films of the 1980sâ¢â¢
</code></pre>

<p>Make a small change to your code (use <a href="https://docs.python.org/2/library/os.html#os.linesep" rel="nofollow">os.linesep</a> instead of <code>'\n'</code>):</p>

<pre><code>import os
import pyperclip
text=pyperclip.paste()     
                             #paste will paste a big string of text in 'text' string

# Separate lines and add stars
lines = text.split(os.linesep)     #lines contains a list of all the individual lines up cut before newline
                             #lines= ['list of iserael films', 'list of italian films' ...]

for i in range(len(lines)):         #loop through all indexes in the "lines" list
    lines[i] = 'â¢â¢' + lines[i] + 'â¢â¢'   #add bullets before and after each line

text = os.linesep.join(lines)         #put a newline in  between the list members (joins them) into a single string
pyperclip.copy(text)
</code></pre>

<p>Generally, a "new line" refers to any set of characters that is commonly interpreted as signaling a new line, which can include:</p>

<ul>
<li>CR LF on DOS/Windows</li>
<li>CR on older Macs</li>
<li>LF on Unix variants, including modern Macs</li>
</ul>

<p>CR is the Carriage Return ASCII character (Code 0x0D), usually represented as \r. LF is the Line Feed character (Code 0x0A), usually represented as \n.</p>

<p>Also, read this: <a href="https://blog.codinghorror.com/the-great-newline-schism/" rel="nofollow">https://blog.codinghorror.com/the-great-newline-schism/</a></p>

<p>I just wanted you to write an platform-agnostic solution. Hence <code>os.linesep</code></p>

python clipboard