Answer:
Step-by-step explanation:
The following python code loops through each line within a file called text.txt and counts all the words, then it divides this count by the number of sentences in the text file. Finally, output the average number of words per sentence.
f = open("text.txt", "r")
all_words = 0
sentences = 0
for x in f:
list = x.split(' ')
all_words += len(list)
sentences += 1
average = all_words / sentences
print("There are an average of " + str(average.__round__()) + " words in each sentence.")