input: Write a function to remove all consecutive duplicates from a given string. The function should iterate through the string, comparing each character with the previous one, and only append the character to the result if it is different from the previous one.
  assert remove_duplicates("AAABBCCCD")=="ABCD"
  assert remove_duplicates("A")=="A"
  assert remove_duplicates("AAA")=="A"
  assert remove_duplicates("")==""
  assert remove_duplicates("AABBCCDDEEFF")=="ABCDEF"
output: def remove_duplicates(s):
      if not s:
          return s
      result = [s[0]]
      for char in s[1:]:
          if char != result[-1]:
              result.append(char)
      return ''.join(result)