new to python here. I am trying to write a program that calculate the average word length in a sentence and I have to do it using the .split command. btw im using python 3.2
In Python 3 (which you appear to be using):
>>> sentence = "Hi my name is Bob" >>> words = sentence.split() >>> average = sum(len(word) for word in words) / len(words) >>> average 2.6