Write a python function to Count the Number of Lines in a Text File
Topic: Write a python function to Count the Number of Lines in a Text File
Solution
def check_lines(): fname = input("file name: ") num_lines = 0 with open(fname, 'r') as f: for line in f: num_lines += 1 print("Number of lines = ", num_lines)
List all Python Programs