You're right that the code you give will not have the desired effect, because strings (unlike lists) are immutable. But slicing comes to your rescue:
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.
Ch
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
Leeds, Mark said unto the world upon 2005-03-16 14:46:
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 statem