└── Reading a file and counting words-1 /Reading a file and counting words-1: -------------------------------------------------------------------------------- 1 | def count_words(filename): 2 | with open(filename, 'r') as file: 3 | text = file.read() 4 | words = text.split() 5 | return len(words) 6 | 7 | print(count_words('example.txt')) 8 | --------------------------------------------------------------------------------