I am in the process of writing a parser in which two lines are compared together (the ‘mainline’ so to speak and the line that came before it). If both of those lines match, the mainline is discarded. I only want this to happen on lines that consist only of newlines or carriage returned newlines. So I have this code
lastline = 0
pointer = 0
for lines in fileLines:
mainline = fileLines[pointer]
if lastline != 0:
print "Last Line: ",lastline
print "This Line: ",mainline
if lastline == '\n' or '\r\n':
if mainline == '\n' or '\r\n':
print "Would drop"
lastline = mainline
pointer = pointer + 1
Every single time it goes through that for loop it will print “Would drop”, when the string is certainly not any of those four options. I figure I’m doing something completely backwards, but I’m teaching python to myself so I don’t really have anyone to tell me when I’m going about something wrong. Thank god you guys are here. Any ideas why this is happening?
Thanks to all of your help it is working perfect. Thanks!!!
is the same as
You want either
or