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

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -