Thanks guys that was fast:<div><br></div><div>I used</div><div>
<span style> for line in users:</span><br style><span style>      fob.write(line + "\n")</span><br style><span style> fob.close()</span> <br>and that works</div><div><br></div><div>Excuse me for the stupid questions, but since one week I read alot of python and I`m confused :p</div>
<div><br></div><div>the only program language I knew in the time was Pascal, but i forgot all of it</div><div><br></div><div>cheers</div><div><br></div><div>Anatoli</div><div><br><div class="gmail_quote">On Fri, Feb 3, 2012 at 9:56 PM, Dave Angel <span dir="ltr"><<a href="mailto:d@davea.name">d@davea.name</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 02/03/2012 03:27 PM, Anatoli Hristov wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi everyone,<br>
<br>
I`m totaly new in python and trying to figure out - how to write a list to<br>
a file with a newline at the end of each object.<br>
I tried alot of combinations :) like:<br>
users = ['toli','didi']<br>
fob=open('c:/Python27/Toli/<u></u>username','w')<br>
fob.writelines(users) + '%s\N'<br>
fob.close()<br>
  or fob.writelines('\N' % users)<br>
or fob.writelines('%s\N' % users)<br>
but nothing of dose works...<br>
<br>
Could you help me find out the right syntaxes?<br>
<br>
Thanks<br>
<br>
</blockquote></div></div>
mylist.writelines() is a shorthand for a loop of writes, once per list item.  It does not append a newline, since if the list had come from readlines(), it would already have the linefeed on each line.<br>
<br>
So you have a few choices.  You could add a newline to each list item before issuing the writelines(), or write your own loop.  I vote for writing your own loop, since there may be other things you want to change on each line.<br>

<br>
1)<br>
  users = [item+"\n" for item in users]        # add a newline to each item<br>
<br>
2)<br>
  for line in users:<br>
       fob.write(line + "\n")<br>
  fob.close()<br>
<br>
There are other possibilities, such as<br>
    contents = "\n".join(mylist)      #make a single string out of it<br>
    fob.write(contents + "\n")        #note we had to add one at the very end,<br>
           #because join just puts the separator between items, not after them.<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
<br>
<br>
-- <br>
<br>
DaveA<br>
<br>
</font></span></blockquote></div><br></div>