There is an error in the code

Report a typo

John has recently started learning algorithms in Python, then he tried to create his first one that counts the average word length in a sentence. Unfortunately, he made an error. Try to find the line(s) with this error and correct it.

Sample Input 1:

I want to go home.

Sample Output 1:

2.6
Write a program in Python 3
sentence = input()

def aver(sent):

for sym in [',', '!', '?', ';', '.', '"', "'"]:
sent = sent.replace(sym, '')

words = sent.split()

total = 0
for word in words:
total = total + len(word)

if len(word) != 0:
result = total / len(word)
else:
result = 0

return result

print(aver(sentence))
___

Create a free account to access the full topic