Reputation: 527
I have a file that contains one line
car
I want to append a new line to the file
when I used this code:
f = open("motors.txt","a")
f.write("Bicycle")
I got the following:
carBicycle
how could I append the new word to a new line
Upvotes: 1
Views: 11335
Reputation:
Prefix Bicycle
with a newline character (\n
) to have it write on a new line:
f.write("\nBicycle")
Upvotes: 3