newbie question: if var1 == var2:
alex23
wuwei23 at gmail.com
Fri Nov 28 23:02:35 EST 2008
On Nov 29, 1:53 pm, joemacbusin... at gmail.com wrote:
> I dont understand why the following code cannot find the
> variable "tree".
>
> fname = open("test43.in")
> var = 'tree'
>
> for item in fname:
This will include the EOL character for each line.
Try adding the following line here:
item = item.strip()
> print "item: ", item,
This would have been more obvious without the trailing ',' which
suppresses a new-line being added when printing.
> if item == var:
> print "found tree: ", item,
More information about the Python-list
mailing list