From 040d2cb8896ff293ee16dcd9eb3f8febbcf0a28a Mon Sep 17 00:00:00 2001 From: pictuga Date: Tue, 23 Oct 2018 00:09:34 +0200 Subject: [PATCH] readabilite: improve word count --- morss/readabilite.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/morss/readabilite.py b/morss/readabilite.py index 30ce0b3..93153ef 100644 --- a/morss/readabilite.py +++ b/morss/readabilite.py @@ -19,12 +19,15 @@ def count_words(string): And so in about every language (sorry chinese). Basically skips spaces in the count. """ + if string is None: + return 0 + i = 0 count = 0 try: while True: - if string[i] not in '\n\t ': + if string[i] not in "\r\n\t ": count += 1 i += 6 else: