From f772ac153f36ed4447676db6b138274157e0fdeb Mon Sep 17 00:00:00 2001 From: nicolasvardas <72015123+nicolasvardas@users.noreply.github.com> Date: Mon, 28 Sep 2020 14:06:59 +0300 Subject: [PATCH] Update solution.py Hello there! I made some changes at word2num function. Now, it will return the final result you asked. --- 18_gematria/solution.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/18_gematria/solution.py b/18_gematria/solution.py index 226eadb21..3ef07dac5 100755 --- a/18_gematria/solution.py +++ b/18_gematria/solution.py @@ -37,8 +37,18 @@ def main(): # -------------------------------------------------- def word2num(word): """Sum the ordinal values of all the characters""" - - return str(sum(map(ord, re.sub('[^A-Za-z0-9]', '', word)))) + word2numList=[] + sum=0 + for i in word: + asciinumber=ord(i) + if (i>47 and i<58) or (i>64 and i<123) : + sum+=asciinumber + else: + if i==32: + word2numList.append(sum) + sum=0 + + return word2numList # --------------------------------------------------