input: Write a python function to implement a Caesar cipher that shifts the letters by a given key.
  assert caesar_cipher('abc', 2) == 'cde'
  assert caesar_cipher('xyz', 3) == 'abc'
  assert caesar_cipher('Hello, World!', 5) == 'Mjqqt, Btwqi!'
  assert caesar_cipher('Python', -2) == 'Nvrfql'
output: def caesar_cipher(text, shift):
      result = []
      for char in text:
          if char.isalpha():
              shift_base = ord('A') if char.isupper() else ord('a')
              shifted_char = chr((ord(char) - shift_base + shift) % 26 + shift_base)
              result.append(shifted_char)
          else:
              result.append(char)
      return ''.join(result)