input: Write a function to encrypt a message using a key in Python. The function should take a message and a key as input, and return the encrypted message. If the key is shorter than the message, it should loop through the key as many times as necessary to encrypt the entire message.
  assert encrypt("Hello world!", "secret")=="Tqxx{,~y|}"
  assert encrypt("Encrypt this!", "key")=="Kujctfx'ymtk#"
  assert encrypt("Password", "1234")=="Qbttxpse"
  assert encrypt("Test", "a")=="Uftu"
  assert encrypt("", "anykey")==""
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():
              if char.islower():
                  encrypted_char = chr((ord(char) - ord('a') + shift) % 26 + ord('a'))
              else:
                  encrypted_char = chr((ord(char) - ord('A') + shift) % 26 + ord('A'))
          else:
              encrypted_char = char
          encrypted_message += encrypted_char
      return encrypted_message