How to replace the last (and only last) character in a string?

Johny python at hope.cz
Thu May 3 10:27:44 EDT 2007


Let's suppose
s='12345 4343 454'
How can I replace the last '4' character?
I tried
string.replace(s,s[len(s)-1],'r')
where 'r' should replace  the last '4'.
But it doesn't work.
Can anyone explain why?

Thanks
L.




More information about the Python-list mailing list