input: Write a function to encrypt a message using a given key in Python. The function should take two parameters: the message to be encrypted and the key used for encryption. The result should be the encrypted message. If the message or key is empty, return the original message.
  assert encrypt("Hello world!", "secret")=="Tqxx{,|/{~"
  assert encrypt("Testing", "key")=="^ittjm["
  assert encrypt("", "key")==""
  assert encrypt("Hello", "")=="Hello"
  assert encrypt("", "")==""
output: def encrypt(message, key):
      if not message or not key:
          return message
      encrypted_message = ""
      key_length = len(key)
      for i, char in enumerate(message):
          shift = ord(key[i % key_length]) - ord('a')
          encrypted_char = chr((ord(char) - ord('a') + shift) % 26 + ord('a'))
          encrypted_message += encrypted_char
      return encrypted_message