Write a function average() that takes no input but requests that the user enters a sentence, i.e. a string. Your function should return the average length of a word in the sentence.

Write a function average() that takes no input but requests that the user enters a sentence, i.e. a string. Your function should return the average length of a word in the sentence.


Usage:
>>> average()
Enter a sentence: Most modern calendars mar the sweet
simplicity of our lives by reminding us that each day
that passes is the anniversary of some perfectly
uninteresting event
5.115384615384615

So far I have this:

def average():
    wordCount = input('Enter a sentence: ')
    sum = 0
    if wordCount != 0:
        average = sum / wordCount
    else:
        average = 0
    return(average)


Learn More :