xclorenzo97 xclorenzo97
  • 12-06-2021
  • Computers and Technology
contestada

How do you find the average length of words in a sentence with Python?

Respuesta :

yme304002
yme304002 yme304002
  • 12-06-2021

Answer:

split() wordCount = len(words) # start with zero characters ch = 0 for word in words: # add up characters ch += len(word) avg = ch / wordCount if avg == 1: print "In the sentence ", s , ", the average word length is", avg, "letter." else: print "In the sentence ", s , ", the average word length is", avg, "letters.

Answer Link

Otras preguntas

what is 4x(12x6-4^2)+9
Using feet or centimeters when measuring length is an example of using a unit of measure. unit of capacity. conversion. similarity.
tohow to instill moral lessons in students​
Which group of people believe they are descendants of the Anasazi?
Non-renewable are still primary sources of energy. True or False
Ethical communication with clients dictates that psychologists will keep their conversations confidential unless required by law. Please select the best answer
Which part of the thirteen colonies is represented by cluster C? Select one: Southern colonies Middle colonies Frontier region New England colonies
HELP ASAP An increasing connectedness and interdependence of world cultures and economies is known as pandemics globalization O living standards localization
Find the absolute maximum and absolute minimum values of f on the given interval. f(t) = 2 cos(t) + sin(2t),[0, π/2].
Change "Are you tired?" to an open-ended question.