From c887ff29ab8f063f9b2dac6bfe6ab6864ebac11c Mon Sep 17 00:00:00 2001 From: deepshekhardas Date: Mon, 20 Jul 2026 12:44:56 +0530 Subject: [PATCH] fix: add input validation to a1z26 encode for non-lowercase chars --- ciphers/a1z26.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ciphers/a1z26.py b/ciphers/a1z26.py index a1377ea6d397..f71cee0fbb68 100644 --- a/ciphers/a1z26.py +++ b/ciphers/a1z26.py @@ -13,7 +13,13 @@ def encode(plain: str) -> list[int]: """ >>> encode("myname") [13, 25, 14, 1, 13, 5] + >>> encode("MyName") + Traceback (most recent call last): + ... + ValueError: only lowercase letters are allowed """ + if plain and not plain.islower(): + raise ValueError("only lowercase letters are allowed") return [ord(elem) - 96 for elem in plain]