input: Write a function to encode a given sentence into Morse code. The function should use a predefined dictionary to map each character to its corresponding Morse code representation. If the input message contains characters not in the dictionary, they should be ignored. The function should return the encoded message as a string of Morse code, with each character separated by a space.
  
  MORSE_CODE = {
   'A': '.-', 'B': '-...',
   'C': '-.-.', 'D': '-..',
   'E': '.', 'F': '..-.',
   'G': '--.', 'H': '....',
   'I': '..', 'J': '.---',
   'K': '-.-', 'L': '.-..',
   'M': '--', 'N': '-.',
   'O': '---', 'P': '.--.',
   'Q': '--.-', 'R': '.-.',
   'S': '...', 'T': '-',
   'U': '..-', 'V': '...-',
   'W': '.--', 'X': '-..-',
   'Y': '-.--', 'Z': '--..',
   '0': '-----', '1': '.----',
   '2': '..---', '3': '...--',
   '4': '....-', '5': '.....',
   '6': '-....', '7': '--...',
   '8': '---..', '9': '----.',
   ' ': ' ', '.': '.-.-.-',
   ',': '--..--', '?': '..--..',
   '/': '-..-.', '-': '-....-',
   '(': '-.--.-', ')': '-.--.-'
  }
  
  def encode(message):
   code = ''
   for letter in message:
    code += MORSE_CODE[letter.upper()] + ' '
   
   return code
  
  assert encode("Hello world") == ".... . .-.. .-.. ---  .-- --- .-. .-.. -.."
  assert encode("SOS") == "... --- ..."
  assert encode("Python") == ".--. -.-- - .... --- -."
  assert encode("123") == ".---- ..--- ...--"
  assert encode("") == ""
  assert encode("!@#$%^&*()") == ""
output: def encode(message):
      code = ''
      for letter in message:
          if letter.upper() in MORSE_CODE:
              code += MORSE_CODE[letter.upper()] + ' '
      return code.strip()