input: 
  def remove_duplicates(string): 
      result = "" 
      prev = '' 
  
      for char in string:
          if char != prev: 
              result += char
              prev = char
      return result
  
  # Test cases
  print(remove_duplicates("AAABBCCCD"))  # Output: "ABCD"
  print(remove_duplicates("A"))          # Output: "A"
  print(remove_duplicates(""))           # Output: ""
  print(remove_duplicates("AAA"))        # Output: "A"
  
output:     for char in string:
          if char != prev: 
              result += char
              prev = char
      return result