This is a modified program from the word count program that I posted about. I am trying to calculate the average word length in a sentence. Here is my code so far:
def main(): print "This program will calculate the average word length in a sentence" print s = raw_input("Enter a sentence: ") words = string.split(s) wordCount = len(words) ch = string.split(words) charCount = len(ch) avgLength = charCount / wordCount print "The average word length of the sentence '", s,"', is", avgLength,"words." main()
I keep getting an error like 'list' object has no attribute 'split'.