<div>Sorry for the double-post.</div><div> </div><div>I don&#39;t think I am wrong either. Replace doesn&#39;t return a list of words in the way that my code sample was setup to do.</div><div>How would you solve it with replace? Maybe an example prove the point better.</div>
<div> </div><div>-Mario<br><br></div><div class="gmail_quote">On Wed, Jun 20, 2012 at 4:10 PM, mariocatch <span dir="ltr">&lt;<a href="mailto:mariocatch@gmail.com" target="_blank">mariocatch@gmail.com</a>&gt;</span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">Yes, I meant split(). Was a typo :)<div class="HOEnZb"><div class="h5">
<br><br><div class="gmail_quote">On Wed, Jun 20, 2012 at 3:56 PM, Prasad, Ramit <span dir="ltr">&lt;<a href="mailto:ramit.prasad@jpmorgan.com" target="_blank">ramit.prasad@jpmorgan.com</a>&gt;</span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">Please always post back to the list.<br>
<div><br>
&gt; Nope, strip() was intended so we get a list back instead of a string. Need<br>
&gt; the list for iteration down below that.<br>
<br>
</div><div>&gt;&gt; &gt;    para = paragraph.strip(&#39;.&#39;).strip(&#39;,&#39;).strip().split()<br>
&gt;&gt; I think you want replace not strip.<br>
&gt;&gt;<br>
&gt;&gt; See <a href="http://docs.python.org/library/stdtypes.html#string-methods" target="_blank">http://docs.python.org/library/stdtypes.html#string-methods</a><br>
<br>
</div>No, you are wrong. If you had looked at the link (or tested the code) you<br>
would find strip() does not do what you think it does.<br>
<br>
What do you mean by &quot;we get a list back instead of a string&quot;? strip does<br>
not return a list...it returns a string. split is what returns the list for<br>
iteration.<br>
<div><br>
<br>
&gt;&gt;&gt; paragraph = &quot;This paragraph contains words once, more than once, and possibly not at all either. Figure that one out. &quot;<br>
</div><div>&gt;&gt;&gt; para = paragraph.strip(&#39;.&#39;).strip(&#39;,&#39;).strip().split()<br>
</div>&gt;&gt;&gt; print para<br>
[&#39;This&#39;, &#39;paragraph&#39;, &#39;contains&#39;, &#39;words&#39;, &#39;once,&#39;, &#39;more&#39;, &#39;than&#39;, &#39;once,&#39;, &#39;and&#39;, &#39;possibly&#39;, &#39;not&#39;, &#39;at&#39;, &#39;all&#39;, &#39;either.&#39;, &#39;Figure&#39;, &#39;that&#39;, &#39;one&#39;, &#39;out.&#39;]<br>


<br>
Note the inclusion of &#39;once,&#39; and &#39;either.&#39; and &#39;out.&#39;. Use replace to remove<br>
punctuation instead and then just compare words. Most probably you want to lower()<br>
or upper() the entire paragraph to be thorough, otherwise &#39;This&#39; and &#39;this&#39;  will<br>
be counted separately.<br>
<div><div><br>
<br>
Ramit<br>
<br>
<br>
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology<br>
712 Main Street | Houston, TX 77002<br>
work phone: <a href="tel:713%20-%20216%20-%205423" target="_blank" value="+17132165423">713 - 216 - 5423</a><br>
<br>
--<br>
<br>
This email is confidential and subject to important disclaimers and<br>
conditions including on offers for the purchase or sale of<br>
securities, accuracy and completeness of information, viruses,<br>
confidentiality, legal privilege, and legal entity disclaimers,<br>
available at <a href="http://www.jpmorgan.com/pages/disclosures/email" target="_blank">http://www.jpmorgan.com/pages/disclosures/email</a>.<br>
_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>