My python readability program is not giving me the correct grade level for all of the checkers.
specifically: "In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since."
should spit out a grade level of 7, but gives me a grade level of 9. All of the other checkers work though! What's going on with this? IS it the way my floats are being rounded? Or am I missing something?
from cs50 import get_string
text = get_string("Text: ")
letters = 0
words = 0
sentences = 0
for i in range(len(text)):
if (text[i] >= 'A' and text[i] <= 'z'):
letters += 1
if (text[i] == ' ' or text[i] == '\0'):
words += 1
if (text[i] == '.' or text[i] == '?' or text[i] == '!'):
sentences += 1
W = 100 / words
L = letters * W
S = sentences * W
grade = round(0.0588 * L - 0.296 * S - 15.8)
if (grade < 1):
print("Before Grade 1")
elif (grade > 16):
print("Grade 16+")
else:
print("Grade ", end = "")
print(grade)