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
s = input("Please enter a sentence: ")
avg_word_len = len(s.replace(' ',''))/len(s.split())
print('Word average =', avg_word_len)
Output:
Please enter a sentence: this is a testing string
Word average = 4.0
note: this is a plain vanilla use case, additional boundary conditions can be applied as required.