here is how you can do it through list comprehension, but this will waste a little bit of your computer's memory as line.strip() has been called twice.
with open('textfile.txt') as file:
lines =[
line.strip()
for line in file
if line.strip() != '']
print("number of lines = {}".format(len(lines)))