def encrypt(message, key):
    """Encrypt message with key."""
    result = ''
    for letter in message:
        if letter.isalpha():
            num = ord(letter)
            if letter.isupper():
                base = ord('A')
            elif letter.islower():
                base = ord('a')
            num = (num - base + key) % 26 + base
            result += chr(num)
        elif letter.isdigit():
            result += letter
        else:
            result += letter
    return result
