From 4fef8b3e599b68c6a93a7a4944eef51557651fac Mon Sep 17 00:00:00 2001 From: Ashvin-KS Date: Sun, 21 Jun 2026 08:30:14 +0530 Subject: [PATCH] fix: add input validation to Caesar cipher Adds validation for empty messages and warns when message contains no alphabetic characters. Closes #1293 --- utilities/Caesar-Cipher/Caesar-Cipher.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utilities/Caesar-Cipher/Caesar-Cipher.py b/utilities/Caesar-Cipher/Caesar-Cipher.py index bba89ccc..d8a8b55f 100644 --- a/utilities/Caesar-Cipher/Caesar-Cipher.py +++ b/utilities/Caesar-Cipher/Caesar-Cipher.py @@ -38,6 +38,13 @@ def main() -> None: elif choice in ["E", "ENCRYPT", "D", "DECRYPT"]: message = input("📝 Enter your message: ") + if not message: + print("❌ Error: Message cannot be empty.\n") + continue + + if not any(c.isalpha() for c in message): + print("⚠️ Warning: Message contains no alphabetic characters. Cipher will return unchanged.\n") + try: shift = int(input("🔑 Enter the shift key (whole number): ")) except ValueError: