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 to be used for encryption. It should return the encrypted message.
  assert encrypt("Hello world!", "secret") == "Tqxx{ y|}|{"
  assert encrypt("Python", "key") == "Wu~sq~"
  assert encrypt("password", "123") == "qqc{~q{n"
  assert encrypt("encryption", "algorithm") == "bvo|ldwwuo"
  assert encrypt("", "key") == ""
output: def encrypt(message, key):
      encrypted_message = ""
      key_length = len(key)
      for i, char in enumerate(message):
          key_char = key[i % key_length]
          encrypted_char = chr((ord(char) + ord(key_char)) % 256)
          encrypted_message += encrypted_char
      return encrypted_message