I have a python file named file_1.py
It has some code in which I just have to change a word: "file_1" to: "file_2" and save it as file_2.py, then again replace 'file_1' with 'file_3' and save it as file_3.py
I have to do this for say 100 times, creating 100 python files: file_1.py,file_2.py......file_100.py
I wrote a code which can replace a string, but I am stuck to write a loop which automates it. Any leads?
with open("path/to/file_1.py") as f:
content = f.read()
new_content = content.replace("file_1","file_2")
with open("path/to/file_2.py", "w") as f:
f.write(new_content)