string - Writing variables to new line of txt file in python -


from other posts, i've learned '\n' signifies new line when adding txt file. i'm trying this, can't figure out right syntax when attribute right before new line.

my code i'm trying this:

for item in list:     open("file.txt", "w") att_file:         att_file.write(variable\n) 

as can see, i'm trying add variable each item in list new line in txt file. what's correct way this?

you need specify newline character string:

eg:

with open("file.txt", "w") att_file:     item in list:         att_file.write(attribute + "\n") 

Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

python 2.7 - Given three nested dictionaries, sort the top two nested dictionaries from a value in the innermost dictionary? -