[Tutor] FW: wierd replace problem

Roelof Wobben rwobben at hotmail.com
Mon Sep 13 21:44:46 CEST 2010




________________________________
> Date: Mon, 13 Sep 2010 15:31:08 -0400
> Subject: Re: [Tutor] FW: wierd replace problem
> From: joel.goldstick at gmail.com
> To: rwobben at hotmail.com
>
>
>
> On Mon, Sep 13, 2010 at 2:24 PM, Roelof Wobben
>> wrote:
>
>
>
> ----------------------------------------
>> From: rwobben at hotmail.com
>> To: joel.goldstick at gmail.com
>> Subject: RE: [Tutor] wierd replace problem
>> Date: Mon, 13 Sep 2010 18:23:36 +0000
>>
>>
>>
>>
>> ________________________________
>>> Date: Mon, 13 Sep 2010 14:18:36 -0400
>>> From: joel.goldstick at gmail.com
>>> To: tutor at python.org
>>> Subject: Re: [Tutor] wierd replace problem
>>>
>>>
>>>
>>> On Mon, Sep 13, 2010 at 2:08 PM, bob gailer
>>>> wrote:
>>> On 9/13/2010 1:50 PM, Roelof Wobben wrote:
>>>
>>> [snip]
>>>
>>> hello Alan,
>>>
>>> Your right. Then it prints like this "'tis
>>> Which is not right. It must be tis.
>>> So the replace does not what it supposed to do.
>>>
>>> Sorry but I am now more confused. After discovering no \ in the text
>>> file now you seem to have have a new specification, which is to get rid
>>> of the '.
>>>
>>> I suggest you give a clear, complete and correct problem statement.
>>> Right now we are shooting in the dark at a moving target.
>>>
>>> Something like.
>>>
>>> Given the file alice_in_wonderland.txt, copied from url so-and-so
>>>
>>> Remove these characters ...
>>>
>>> Split into words (not letters?) where word is defined as
>>>
>>> Count the frequency of each word.
>>>
>>>
>>> --
>>> Bob Gailer
>>> 919-636-4239
>>> Chapel Hill NC
>>>
>>> _______________________________________________
>>> Tutor maillist - Tutor at python.org
>>> To unsubscribe or change subscription options:
>>> http://mail.python.org/mailman/listinfo/tutor
>>>
>>> How about using str.split() to put words in a list, then run strip()
>>> over each word with the required characters to be removed ('`")
>>>
>>> --
>>> Joel Goldstick
>>>
>>>
>>> _______________________________________________ Tutor maillist -
>>> Tutor at python.org To unsubscribe or change
> subscription options:
>>> http://mail.python.org/mailman/listinfo/tutor
>>
>
> Hello Joel.
>
> That can be a solution but when i have --dark the -- must be removed.
> But in a-piece the - must not be removed.
>
> Roelof
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
> strip only removes from start and end of string. Not from the middle,
> so a-piece would stay as a word
>
> --
> Joel Goldstick
>
 
Oke, 
 
I have tried that but then I see this message :
 
 File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 8
    letter2 = letter.strip('`")
                              ^
SyntaxError: EOL while scanning string literal
 
Change it to (''`"") do not help either.
 
Roelof

  		 	   		  


More information about the Tutor mailing list