diff --git a/cipher.py b/cipher.py index 0e772db..b71f61a 100644 --- a/cipher.py +++ b/cipher.py @@ -1 +1,14 @@ -# add your code here +def caesar_cipher(text, shift): + result = "" + for char in text: + if char.isalpha(): + shift_amount = 65 if char.isupper() else 97 + result += chr((ord(char) - shift_amount + shift) % 26 + shift_amount) + else: + result += char + return result + +text = "python is fun!" +shift = 5 +encrypted_text = caesar_cipher(text, shift) +print("Encrypted text:", encrypted_text)