How to strip line breaks from BeautifulSoup get text method
<p>I have a following output after scraping a web page</p>

<pre><code>       text
Out[50]: 
['\nAbsolute FreeBSD, 2nd Edition\n',
'\nAbsolute OpenBSD, 2nd Edition\n',
'\nAndroid Security Internals\n',
'\nApple Confidential 2.0\n',
'\nArduino Playground\n',
'\nArduino Project Handbook\n',
'\nArduino Workshop\n',
'\nArt of Assembly Language, 2nd Edition\n',
'\nArt of Debugging\n',
'\nArt of Interactive Design\n',]
</code></pre>

<p>I need to strip \n from above list while iterating over it. Following is my code</p>

<pre><code>text = []
for name in web_text:
   a = name.get_text()
   text.append(a)
</code></pre>

<p>You can use <a class='doc-link' href="http://stackoverflow.com/documentation/python/196/comprehensions/737/list-comprehensions#t=201610050931583559832">list comprehension</a>:</p>

<pre><code>stripedText = [ t.strip() for t in text ]
</code></pre>

<p>Which outputs:</p>

<pre><code>&gt;&gt;&gt; stripedText
['Absolute FreeBSD, 2nd Edition', 'Absolute OpenBSD, 2nd Edition', 'Android Security Internals', 'Apple Confidential 2.0', 'Arduino Playground', 'Arduino Project Handbook', 'Arduino Workshop', 'Art of Assembly Language, 2nd Edition', 'Art of Debugging', 'Art of Interactive Design']
</code></pre>

python beautifulsoup