From 1ff77c161215a8d5a5c99e0b28949a3e108df9db Mon Sep 17 00:00:00 2001 From: MadhavGupta1506 Date: Fri, 8 Nov 2024 22:31:28 +0530 Subject: [PATCH 1/4] Fix:Used list instead of string in rot13.py and removed n --- ciphers/rot13.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ciphers/rot13.py b/ciphers/rot13.py index b367c3215127..f8a5c64abf80 100644 --- a/ciphers/rot13.py +++ b/ciphers/rot13.py @@ -1,4 +1,4 @@ -def dencrypt(s: str, n: int = 13) -> str: +def dencrypt(s: str) -> str: """ https://en.wikipedia.org/wiki/ROT13 @@ -9,7 +9,8 @@ def dencrypt(s: str, n: int = 13) -> str: >>> dencrypt(s) == msg True """ - out = "" + out = [] + n=13 for c in s: if "A" <= c <= "Z": out += chr(ord("A") + (ord(c) - ord("A") + n) % 26) @@ -17,16 +18,16 @@ def dencrypt(s: str, n: int = 13) -> str: out += chr(ord("a") + (ord(c) - ord("a") + n) % 26) else: out += c - return out + return ''.join(out) def main() -> None: s0 = input("Enter message: ") - s1 = dencrypt(s0, 13) + s1 = dencrypt(s0) print("Encryption:", s1) - s2 = dencrypt(s1, 13) + s2 = dencrypt(s1) print("Decryption: ", s2) From 1f681f5b9724d73e6c20aa473a30d8921eb13d0b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:13:42 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ciphers/rot13.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ciphers/rot13.py b/ciphers/rot13.py index f8a5c64abf80..8b99714871f8 100644 --- a/ciphers/rot13.py +++ b/ciphers/rot13.py @@ -10,7 +10,7 @@ def dencrypt(s: str) -> str: True """ out = [] - n=13 + n = 13 for c in s: if "A" <= c <= "Z": out += chr(ord("A") + (ord(c) - ord("A") + n) % 26) @@ -18,7 +18,7 @@ def dencrypt(s: str) -> str: out += chr(ord("a") + (ord(c) - ord("a") + n) % 26) else: out += c - return ''.join(out) + return "".join(out) def main() -> None: From 1a61d46d1d0dc1ee83684344d26473f0b331e70a Mon Sep 17 00:00:00 2001 From: MadhavGupta1506 Date: Sat, 9 Nov 2024 16:25:36 +0530 Subject: [PATCH 3/4] Used-list-instead-of-string-in-rot13.py-and-removed-n --- ciphers/rot13.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciphers/rot13.py b/ciphers/rot13.py index 8b99714871f8..07be75356aff 100644 --- a/ciphers/rot13.py +++ b/ciphers/rot13.py @@ -9,7 +9,7 @@ def dencrypt(s: str) -> str: >>> dencrypt(s) == msg True """ - out = [] + out:list[str] = [] n = 13 for c in s: if "A" <= c <= "Z": From d14c943002874588941c8d84aca09e1da4b99f36 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 9 Nov 2024 11:00:38 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ciphers/rot13.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciphers/rot13.py b/ciphers/rot13.py index 07be75356aff..74f52ad97991 100644 --- a/ciphers/rot13.py +++ b/ciphers/rot13.py @@ -9,7 +9,7 @@ def dencrypt(s: str) -> str: >>> dencrypt(s) == msg True """ - out:list[str] = [] + out: list[str] = [] n = 13 for c in s: if "A" <= c <= "Z":