On Fri, 2008-11-28 at 19:47 -0800, [EMAIL PROTECTED] wrote: > Hi All, > > I dont understand why the following code never finds "tree".
The problem is that the lines you are reading from the file have a newline at the end so 'tree' != 'tree\n'. See below for suggested changes. > I could not find the answer in the Python tutorials. > Here is the code, test43.in, and runtime: > > #!/usr/bin/python > > fp = open("test43.in") > var = 'tree' > > for item in fp: item = item.strip() # Strip off white space # No commas necessary at the end of the prints # now that we've removed the newlines. > print "item:", item > if item == var: > print "found tree:", item Hope this helps you understand what was happening. Have fun with python! -Reggie -- http://mail.python.org/mailman/listinfo/python-list