as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
write a python function that encrypts a message using the caesar cipher.
user
def caesar_encrypt(message, key):
    encrypted_message = ""
    for char in message:
        if char.isalpha():
            num = ord(char)
            num += key
            if char.isupper():
                if num > ord('z'):
                    num -= 26
                elif num < ord('a'):
                    num += 26
            elif char.islower():
                if num > ord('z'):
                    num -= 26
                elif num < ord('a'):
                    num += 26
            encrypted_message += chr(num)
        else:
            encrypted_message += char
    return encrypted_message
assistant