Question 1: Write a Python program to count the number of words in a text file DS301222

filename=input(“give a file name :”)
num_words=0
with open(filename,‘r’) as f:
for line in f:
words=line.split()
num_words+=len(words)
print(“num of words”)
print(num_words)

3 Likes

@kinnukeshiya correct Keep Practicing

good going @kinnukeshiya