I am using Python to create a text file with some text inside.
I need these files to stay saved, but have the same name at the same time, since currently, Python overwrites the old text file with the same name, and the old data gets deleted.
I have tried using os.rename(f"file_name_x.txt)
, where x is a number that is incremented each time. This did not work as the program restarts and x is declared as the same old integer and the file is replaced again.
The intended result is to have something like this:
file_name_1.txt
file_name_2.txt
file_name_3.txt
...
I'm still trying new methods after posting this but if someone knows a workaround to this, it would be great