string methods

anthonyberet nospam at me.invalid
Sat Jul 30 11:15:10 EDT 2005


I am an abject newbie, so mock away (actually no-one ever does that in 
this group..)

Anyway, I want to replace one character in a string, based in that 
character's position in the string.

For example if I wanted to replace the 4th character in 'foobar' (the 
b)with the contents of another string, newchar, what would be the 
easiest way?

I know this touches on immutability etc, but I can't find string methods 
to return the first 3 characters, and then the last 2 characters, which 
I could concatenate with newchar to make a new string.

I know the string methods are there, but can't find it in any docs, and 
just want to check the syntax, unless there is an easier way.

Thanks.



More information about the Python-list mailing list