# Basic syntax:
count = len(open('/path/to/the/file.ext').readlines())
num_lines = sum(1 for line in open('myfile.txt'))
# open file in read mode
with open(r"E:demosfiles
ead_demo.txt", 'r') as fp:
for count, line in enumerate(fp):
pass
print('Total Lines', count + 1)
# You can do it by iterating through a simple for loop
fhand = open('path and the file name')
count = 0
for line in fhand:
count += 1
print('The number of lines in the file is:', count)