How to break a sentence in python depending on fullstop '.'?
<p>I writing a script in python in which I have the following string:</p>

<pre><code>a = "write This is mango. write This is orange."
</code></pre>

<p>I want to break this string into sentences and then add each sentence as an item of a list so it becomes:</p>

<pre><code>list = ['write This is mango.', 'write This is orange.']
</code></pre>

<p>I have tried using TextBlob but it is not reading it correctly.(Reads the whole string as one sentence).</p>

<p>Is there a simple way of doing it?</p>

<p>One approach is <a href="https://docs.python.org/2/library/re.html#re.split" rel="nofollow"><code>re.split</code></a> with <em>positive lookbehind</em> assertion:</p>

<pre><code>&gt;&gt;&gt; import re
&gt;&gt;&gt; a = "write This is mango. write This is orange."
&gt;&gt;&gt; re.split(r'(?&lt;=\w\.)\s', a)
['write This is mango.', 'write This is orange.']
</code></pre>

<p>If you want to <em>split</em> on more than one separator, say <code>.</code> and <code>,</code>, then use a character set in the assertion:</p>

<pre><code>&gt;&gt;&gt; a = "write This is mango. write This is orange. This is guava, and not pear."
&gt;&gt;&gt; re.split(r'(?&lt;=\w[,\.])\s', a)
['write This is mango.', 'write This is orange.', 'This is guava,', 'and not pear.']
</code></pre>

<hr>

<p>On a side note, you should not use <code>list</code> as the name of a variable as this will <em>shadow</em> the builtin <code>list</code>.</p>

python list