''' Purpose: examine a list of words ''' # get text from user reply = input( 'Enter text: ' ) print() # split text into words words = reply.split() # let's see what we got print( 'Supplied text =', reply ) print( 'words =', words ) print() # determine number of words n = len( words ) # number of words in words # determine total word length sum_of_word_lengths = 0 # total accumulator variables start off at 0 for w in words : # get current word's length print( "w:", w ) length_of_current_word = len( w ) print( "length_of_current_word:", length_of_current_word ) # add length to the accummulation sum_of_word_lengths = sum_of_word_lengths + length_of_current_word print( "sum of word lengths:", sum_of_word_lengths ) print() # determine average average_word_length = sum_of_word_lengths / n print( 'Average word length:', average_word_length )