Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fname = input("Enter file name: ")
- num_words = 0
- with open(fname, 'r') as f:
- for line in f:
- words = line.split()
- num_words += len(words)
- print("Number of words:")
- print(num_words)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement