Reputation: 11
Whenever I execute this piece of code more than once, my data is stored, but not in separate lines every time the user inputs a new data.
I have already tried to use "/n"
, but in lieu of a new line, the command "/n"
itself gets written to my file.
What can I do to enter the data in separate new lines?
file = open(f"{fileName}.txt", "a")
file.write("Text to write...")
file.close()
Upvotes: 0
Views: 53
Reputation: 1306
You need to use \n
and not /n
, like so:
file = open(f"{fileName}.txt", "a")
file.write("\nText to write...")
file.close()
Upvotes: 1