input: Write a function to encode a given string into Pig Latin.
  assert latin_encode("hello world") == "ellohay orldway "
  assert latin_encode("python is fun") == "ythonpay isay unfay "
  assert latin_encode("i love programming") == "iay ovelay rogrammingpay "
output: def latin_encode(s):
      def encode_word(word):
          if word[0] in 'aeiouAEIOU':
              return word + 'ay'
          else:
              return word[1:] + word[0] + 'ay'
  
      return ' '.join(encode_word(word) for word in s.split()) + ' '