lundi 14 juin 2021

Python if statement displaying 0 and 0.0 as unequal [duplicate]

I am trying to write an if statement that displays any differences between two excel files (if any). It seems to be working but it displays every line and the only difference I can see is that one file uses 0 and one uses 0.0. Is there a fix for this? The code:

while True:
lineF = f.readline().strip()
lineG = g.readline().strip()
line += 1

if (lineF != lineG):
    if (lineF != lineG):
        print("Line %d:\n%s\nvs\n%s\n" %(line, lineF, lineG))
else:
    f.close()
    g.close()
    break

Aucun commentaire:

Enregistrer un commentaire