diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-05-04 23:20:24 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-05-04 23:20:24 +0000 |
commit | a005aa6910a6a9e1c22707d036c280a88e076b00 (patch) | |
tree | 8db37cc382951c1a46ea6a63aa100ef067513b47 /wk6/pset/sentimental-readability/readability.py | |
parent | 211af0529303c1edea1cc48905813002b9d9424b (diff) |
Sat, May 4, 2024, 4:20 PM -07:00
Diffstat (limited to 'wk6/pset/sentimental-readability/readability.py')
-rw-r--r-- | wk6/pset/sentimental-readability/readability.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/wk6/pset/sentimental-readability/readability.py b/wk6/pset/sentimental-readability/readability.py index 7e06180..16750f5 100644 --- a/wk6/pset/sentimental-readability/readability.py +++ b/wk6/pset/sentimental-readability/readability.py @@ -8,10 +8,18 @@ l = 0.0 # letters c = '' for i in range(len(text)): + # get the current letter c = text[i] + # save the ascii value for later j = ord(c.lower()) + # if this is the end of a sentence add one to sentences if c == '.' or c == '!' or c == '?': s += 1 + # if this is the end of a word add one to words elif c == ' ': w += 1 - elif + # if this is a letter add one to letters + elif 96 < j and j < 123: + l += 1 + +print(s, w, l, c) |