From 9b77b9f7a3c0c127f648f724c08858167d50c708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Fern=C3=A1ndez=20Serrata?= <76864299+Rudxain@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:29:28 -0400 Subject: [PATCH] fix "\n" conversion in helpers.py --- src/helpers.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/helpers.py b/src/helpers.py index ea441b3..5697e7a 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -31,22 +31,21 @@ def remove_all(l: list, x): return l def filter_str(s:str): + """ + Remove 1st and last chars, and + replace line-feed literals with actual line-feeds. + """ res = "" i = 1 while i < len(s) - 1: - if s[i] == '\\': - if s[i + 1] == 'n': - res += '\n' - i += 1 + if s[i] == '\\' and s[i + 1] == 'n': + res += '\n' + i += 2 else: res += s[i] i += 1 return res -# filter_str: Final[Callable[[str], str]] = lambda s: s[1:-1] -"""Remove 1st and last chars from a `str`.""" - - def precedence(op: str): """ Get precedence of basic arithmetic operators (+ - * /).