Caesar cipher is an ancient cipher first used in Roman days.
The way it worked was to shift each letter of the alphabet by a certain amount.
For example, if the shift was 1 abc xyz would become bcd yza
(z wraps back around to a). If the shift was 2 then the message cat would become ecv.
Your task is to create a function called caesar_shift(msg, n) where msg is
a string containing the message and n is number of positions the message should
be shifted by.
Here are some things that might be useful:
import string
alphabet = string.ascii_lowercase
# Prints 'abcdefghijklmnopqrstuvwxyz'
print(alphabet)
# Prints '3' (a = 0, b = 1, ...)
print(alphabet.index('d'))
# Prints 4 (% returns the remainder of the division - look into modular arithmetic)
print(30 % len(alphabet))
Test it
Try running caesar_shift('cat', 2), it should equal ecv.
Extension
What happens if your message contains both upper and lowercase letters?
How does you program handle that case? How should it handle that case?
What if the message contains a space? Make sure your program keeps the space
as it is without changing it when the text is shifted.