newbie question: if var1 == var2:
![](https://secure.gravatar.com/avatar/870f5aa0e1f9e63f637d28b1c86f08b1.jpg?s=120&d=mm&r=g)
Nov. 29, 2008
3:47 a.m.
Hi All, I dont understand why the following code never finds "tree". I could not find the answer in the Python tutorials. Here is the code, test43.in, and runtime: #!/usr/bin/python fname = open("test43.in") var = 'tree' for item in fname: print "item: ", item, if item == var: print "found tree: ", item, [jmccaughan@dhcppc2 work]$ [jmccaughan@dhcppc2 work]$ [jmccaughan@dhcppc2 work]$ cat test43.in car tree house pool dog cat wax candy bar [jmccaughan@dhcppc2 work]$ python test43.py item: car item: tree item: house item: pool item: dog item: cat item: wax item: candy bar Thanks, joemacbusiness@gmail.com
5923
Age (days ago)
5923
Last active (days ago)
0 comments
1 participants
participants (1)
-
joemacbusiness@gmail.com