From cbe813b8ff5aa50229696ecf040a3b5d8511d557 Mon Sep 17 00:00:00 2001 From: pythonboi Date: Tue, 14 Sep 2021 02:51:32 -0400 Subject: [PATCH] add a conditinal statement for encrypt and decrypt --- Caesar_Cipher.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Caesar_Cipher.py b/Caesar_Cipher.py index 25a49ad..deb73ed 100644 --- a/Caesar_Cipher.py +++ b/Caesar_Cipher.py @@ -52,6 +52,7 @@ # BETTER COPY + def encrypt(text, shift): newEn = '' for count in text: @@ -65,7 +66,7 @@ def encrypt(text, shift): else: newEn += alphabet[en] # print(en) - print(newEn) + print(f"The encode text is {newEn}") # newEn) def decrypt(text, shift): @@ -74,9 +75,10 @@ def decrypt(text, shift): getDecry = alphabet.index(check) - shift deNew += alphabet[getDecry] - print(deNew) - + print(f"The decoded text is {deNew}") -encrypt(text=text, shift=shift) -decrypt(text=text, shift=shift) +if direction == "encode": + encrypt(text=text, shift=shift) +elif direction == "decode": + decrypt(text=text, shift=shift)