input: Write a function to encrypt a message using a key in Python.
  assert encrypt("Hello world!", "secret")=="Tqxx{,oxod}"
  assert encrypt("Test message", "key")=="Xo{{ vkzkv~m"
  assert encrypt("Python", "code")=="V{wyvi"
  assert encrypt("", "abc")==""
  assert encrypt("Encrypt this", "password")=="Mxobq}vo+dqi"
output: def encrypt(message, key):
      encrypted_message = ""
      key_length = len(key)
      for i, char in enumerate(message):
          shift = ord(key[i % key_length]) - ord('a')
          if char.isalpha():
              base = ord('A') if char.isupper() else ord('a')
              encrypted_message += chr((ord(char) - base + shift) % 26 + base)
          else:
              encrypted_message += char
      return encrypted_message