newbie : modifying a string in python

Leeds, Mark mleeds at mlp.com
Wed Mar 16 14:46:16 EST 2005


I want to modify a string in the following way :

 

for s in stks:

      s = s.strip()

      if ( s[-2:] == 'GR' ):

              s[-2:]= 'GF'

 

so, if the last two characters are GR, I want to change

them to GF ( there will be other if statements also but I am

just putting this one here for simplicity ).

 

I think the code is fine but I vaguely remember

reading somewhere in the documentation that

python strings can't be changed ( only elements of lists can be ) ?.

Is that true or is it okay to do the above.

.

                                   thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050316/4fbd0f04/attachment.html>


More information about the Python-list mailing list