prateek prateek - 6 months ago 33
Python Question

Search and replace operation

I have a list which has URL values like:

How can I change the
in the end to
for all occurrences?


Try this:

str = ""
str = str.replace("_s","_m")

If you want to be sure that only the las part is changed and you know all are .jpg files you can use:

str = ""
str = str.replace("_s.jpg","_m.jpg")

To give some more context and avoid changes on the middle of the url.