hi I have a string like this:
path = "/level1/level2/level3/file.csv"
I want to do a operation in 2 steps like first is want to replace file name for example
path = "/level1/level2/level3/file_1.csv"
and in some cases only folder which is 2nd last from end like this
path = "/level1/level2/level3_1/file.csv"
so what will be best way to do this ? currently I am doing like this
path.replace('level3','level3_1')
but It got failed when there is same name exist somewhere else in string ...
/. Replace. Join back.pathlib.