def encrypt(message)
# The way you show it in the video is more elegant, but I came up with an alternate solution.
# Any symbols show up as 0 if they go through the mapping, so I made an if statement
# encryption function
def encrypt(message):
MAPPING = {
'A': 'N',
'B': 'O',
'C': 'P',
'D': 'Q',
'E': 'R',
'F': 'S',
'G': 'T',
'H': 'U',
'I': 'V',
'J': 'W',
'K': 'X',
'L': 'Y',
'M': 'Z',
'N': 'A',
'O': 'B',
'P': 'C',
'Q': 'D',
'R': 'E',
'S': 'F',
'T': 'G',
'U': 'H',
'V': 'I',
'W': 'J',
'X': 'K',
'Y': 'L',
'Z': 'M'
}
message = message.upper()
encrypted = []
for cypher in message:
swap = MAPPING.get(cypher, 0)
if swap == 0:
encrypted.append(" ")
else:
encrypted.append(swap)
return ''.join(encrypted)