J
joemacbusiness
Hi All,
I dont understand why the following code cannot find the
variable "tree". It is very simple but I could not find the answer
to this on the Python Tutorials. Here is the code, input 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
[jmccaughan@dhcppc2 work]$
Thanks for the help, (e-mail address removed)
I dont understand why the following code cannot find the
variable "tree". It is very simple but I could not find the answer
to this on the Python Tutorials. Here is the code, input 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
[jmccaughan@dhcppc2 work]$
Thanks for the help, (e-mail address removed)