Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cipher.py
Original file line number Diff line number Diff line change
@@ -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)