+ 3

Check what's wrong in this code

Average lenght of word in a sentence https://code.sololearn.com/c15cO2sD7LNi/?ref=app

2nd Feb 2020, 5:50 AM
N S
3 Réponses
+ 3
on another note, while this exercise only requires removing the question mark, here's a better alternative for removing non-alphabet characters: import string alphabet = string.ascii_lowercase + " " sentence = input().strip() new = "" for char in sentence: if char in alphabet: new += char ...
2nd Feb 2020, 7:58 AM
grdr
+ 3
Tysm for guiding me in this problem
2nd Feb 2020, 8:31 AM
N S
+ 2
just read the error message given when trying to run your code. it clearly states you're trying to divide (/) a list by an integer which obviously doesn't work. the reason is that you have mismatched parentheses in line 11. here's the correct version: average=sum(len(word) for word in words) / len(words) for the future, try to Google the error messages you get on runtime. eventually, you'll understand them yourself right away. note that the code will run after changing this but it won't solve the challenge still. you can try to go from there or take a look at my code: from math import ceil sentence = input().replace("?", "") words = sentence.strip().split() chars = 0 for word in words: chars += len(word) average = ceil(chars / len(words)) print(int(average))
2nd Feb 2020, 7:48 AM
grdr