Computer Science, asked by ojitoinams2282, 1 year ago

Write a program to find number of lines , words and characters in a file


LuckyYadav2578: in which language

Answers

Answered by farfromsubtle
0

Hey there! A program I did as a quick exercise in Python could fit the bill: however I did use the built in (len) function. If that's not what you're looking for, let me know.

fname = "feed.txt"

num_lines = 0

num_words = 0

num_chars = 0

with open(fname, 'r') as f:

   for line in f:

       words = line.split()

       num_lines += 1

       num_words += len(words)

       num_chars += len(line)

Similar questions