You have invented a time-machine which has taken you back to ancient Rome. Caeser is impressed with your programming skills and has appointed you to be the new information security officer.

Caeser has ordered you to write a Caeser cipher to prevent Asterix and Obelix from reading his emails.

A Caeser cipher shifts the letters in a message by the value dictated by the encryption key. Since Caeser's emails are very important, he wants all encryptions to have upper-case output, for example:

If key = 3
"hello" -> KHOOR
If key = 7
"hello" -> OLSSV

Input will consist of the message to be encrypted and the encryption key.

Source: codewars | Difficulty: EASY

Starter code: def caeser(message, key):
	

Solutions:
def caeser(message, key):
	return ''.join((chr(65 + (ord(c.upper()) + key - 65) % 26) if c.isalpha() else c for c in message))


def caeser(message, key):
	return ''.join((chr(ord(x) + key if ord(x) + key <= 122 else ord(x) + key - 122 + 96).upper() if x.isalpha() else x for x in message))


import string

def caeser(message, key):
	return ''.join([chr((ord(s.upper()) + key - 65) % 26 + 65) if s in string.ascii_lowercase else s for s in message])


def caeser(m, k):
	r = ''
	M = m.upper()
	for c in M:
		if c >= 'A' and c <= 'Z':
			r += chr(65 + (ord(c) - 65 + k) % 26)
		else:
			r += c
	return r


def caeser(message, key):
	return ''.join(('ABCDEFGHIJKLMNOPQRSTUVWXYZ'[('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.index(el) + key) % len('ABCDEFGHIJKLMNOPQRSTUVWXYZ')] if el in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' else el for el in message.upper()))


def caeser(message, key):
	return ''.join((char_if(c, key) for c in message.upper()))

def char_if(char, key):
	alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	return alpha[(alpha.index(char) + key) % 26] if char in alpha else char


def caeser(m, k):
	m = m.lower()
	return ''.join([chr((ord(i) - ord('a') + k) % 26 + ord('a')).upper() if i.isalpha() else i for i in m])


import string

def caeser(message, key=1):
	letters = string.ascii_lowercase
	mask = letters[key:] + letters[:key]
	trantab = str.maketrans(letters, mask)
	return message.translate(trantab).upper()