I need help finding the average number of words per sentence, within a list
# This program reads numbers from a file into a list.
# Open a file for reading.
infile = open('text.txt', 'r')
sentences = infile.readlines() # Read the contents of the file into a list.
infile.close() # Close the file.
index = 0 # Convert each element to an int.
while index < len(sentences):
print (sentences[index], index) #PRINT EACH ELEMENT
index += 1
# Print the contents of the list.
# Call the main function.
5 Months Ago
Related Article:I need some help with a binary(?) calculator
is a solved Python discussion thread by ThePythonNoob that has 2 replies, was last updated 10 months ago and has been tagged with the keywords: binary, random, python.
Take a page containing a list of sentences, like this one (take only the first 5 sentences). Then with a calculator, compute the average number of words per sentence by hand and note carefully everything you do. This should give you a working algorithm. Write pseudo code, then python code.