I am trying to write a string Test string: Correct
before the }
in the input file, input.txt
.
The input file looks like the following:
{
File name: test.txt
File contents : valid
File type: txt
Test string: Correct <- this is what i want to add here before the } at the end of the file
}
My code is below. I am not able to figure out how to add the test_string
before the last }
in the file. May someone please guide me?
test_string = "Test string: Correct"
with open(test.txt, "a") as file:
file.write(test_string + "\n")