for s in stks:
s = s.strip()
if s[-2:] == 'GR':
s = s[:-2] + 'GF'
-- though I'm sure more experienced people will offer more efficient solutions.
Charles Hartman
Professor of English, Poet in Residence
http://cherry.conncoll.edu/cohar
http://villex.blogspot.com
<x-tad-bigger> 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.
</x-tad-bigger>
-- http://mail.python.org/mailman/listinfo/python-list