EDITED: initial code contained error. Blank lines contain newline at end, so line must be stripped otherwise it will be truthy (contains newline). Therefore row.strip() should be used. Below code is fixed.
............
From screenshot I observe that there is blank line at the end of file. Problem can be easily mitigated by little defensive code - 'check whether line is empty'. Also I suggest to open files using 'with', among other goodies there is no need to close file - Python does it for you.
............
From screenshot I observe that there is blank line at the end of file. Problem can be easily mitigated by little defensive code - 'check whether line is empty'. Also I suggest to open files using 'with', among other goodies there is no need to close file - Python does it for you.
with open('filename.txt', 'r') as f: for row in f: if row.strip(): # the rest of code
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.