# CSE 142 Python sessions # This program creates a secret message using a simple encryption algorithm # called a Caesar cipher, which shifts each letter ahead by 3 places. # # Sample log of execution: # Enter your message: Attack the zombies at dawn! # The encoded message is: dwwdfn wkh crpelhv dw gdzq! def code(message, shift): message = message.lower() codedMessage = "" for x in message: if x in "abcdefghijklmnopqrstuvwxyz": num = ord(x) num += shift if num > ord("z"): # wrap if necessary num -= 26 codedMessage = codedMessage + chr(num) else: codedMessage = codedMessage + x return codedMessage # main program shift = 3 msg = input("Enter your message: ") codedMessage = code(msg,shift) print("The encoded message is:", codedMessage)