Thanks, that helped. I took a second look and realized where I had tried calling the .strip() method was wrong. Appreciate the pointer.<div><br>Becky <br><br><div class="gmail_quote">On Thu, Mar 3, 2011 at 5:37 PM, Kushal Kumaran <span dir="ltr"><<a href="mailto:kushal.kumaran%2Bpython@gmail.com">kushal.kumaran+python@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Fri, Mar 4, 2011 at 6:48 AM, Becky Mcquilling <<a href="mailto:ladymcse2000@gmail.com">ladymcse2000@gmail.com</a>> wrote:<br>
> I am creating a dictionary by parsing a text file.<br>
><br>
> The code is below:<br>
> backup_servers = {}<br>
> fo = open('c:/test/backup_shares.txt')<br>
> for line in fo:<br>
> backup_server = line.split(',')<br>
> backup_servers[backup_server[0]]=backup_server[1]<br>
<br>
</div>Looping over a file object returns lines including the trailing<br>
newline. If that's not required, you have to remove the newline at<br>
the end yourself using the strip method.<br>
<br>
To see the behaviour, print out the value of line at the start of the loop body.<br>
<br>
Documentation on file objects:<br>
<a href="http://docs.python.org/library/stdtypes.html#file-objects" target="_blank">http://docs.python.org/library/stdtypes.html#file-objects</a><br>
Documentation on strings:<br>
<a href="http://docs.python.org/library/stdtypes.html#string-methods" target="_blank">http://docs.python.org/library/stdtypes.html#string-methods</a><br>
<br>
> <snip><br>
<br>
--<br>
regards,<br>
<font color="#888888">kushal<br>
</font></blockquote></div><br></div>