I have a file named test.txt that contains the following:
Line 1
Line 2
Line 3
Line 4
I have simple Python program like this:
f = open("test.txt")
myline = "Line 3"
for line in f:
print myline + " - " + line
if myline == line:
print "We have a match!"
if myline == "Line 3":
print "This works."
I got this result:
Line 3 - Line 1
Line 3 - Line 2
Line 3 - Line 3
Line 3 - Line 4
This works.
Why doesn't "We have a match!" get printed?
What did I miss?