How does one go about replacing terms in a string - except for the last, which needs to be replaced to something different?
An example:
letters = 'a;b;c;d'
needs to be changed to
letters = 'a, b, c & d'
I have used the replace function, as below:
letters = letters.replace(';',', ')
to give
letters = 'a, b, c, d'
The problem is that I do not know how to replace the last comma from this into an ampersand. A position dependent function cannot be used as there could be any number of letters e.g 'a;b' or 'a;b;c;d;e;f;g' . I have searched through stackoverflow and the python tutorials, but cannot find a function to just replace the last found term, can anyone help?