Ari Madian Ari Madian - 11 months ago 20
Python Question

How to write a variable to a file on a new line every time?

I am trying to put a variable in to a file and have it go on a new line every time. For example,


This has already been asked with how to write it as a string like
and to do it that way, you just do "/n" but that doesn't work with variables for some reason.

I've tried this as:

file.write(variable + '/n')

None of those worked. Thanks for the help!


You are using a forward slash /n and you need to use a backslash \n.