input: Write a python function to encode a string by shifting each character by a given amount.
  assert encode_string("abc", 1) == "bcd"
  assert encode_string("xyz", 2) == "zab"
  assert encode_string("hello world", 3) == "khoor zruog"
output: def encode_string(s, shift):
      encoded = []
      for char in s:
          if char.isalpha():
              offset = 65 if char.isupper() else 97
              encoded_char = chr((ord(char) - offset + shift) % 26 + offset)
              encoded.append(encoded_char)
          else:
              encoded.append(char)
      return ''.join(encoded)