Program:
file_path= "abc.txt" #Only file name if Program and this txt file in same Directory.
no_lines=0
no_words=0
no_chars=0
with open(file_path, 'r') as f:
for line in f:
words = line.split()
no_lines += 1
no_words += len(words)
no_chars += len(line)
print(f"\t\t::::::::In the {file_path} file::::::\n\
Number of Line: {no_lines}\n\
Number of Words: {no_words}\n\
Number of Charactors: {no_chars}")
Expected O/P:
::::::::In the abc.txt file::::::
Number of Line: 7
Number of Words: 119
Number of Charactors: 576
Click here for->> abc.txt
0 Comments
Post a Comment