input: Write a function to compress a given string by replacing all repeating characters with a single instance and its count. The function should return the compressed string. If the input string is empty, the function should return an empty string.
  
  def compress(s): 
      if not s:
          return ""
      
      # Initialize results 
      output = "" 
    
      # Initialize count 
      count = 1
    
      # Traverse the string 
      for i in range(1, len(s)): 
            
          # If the current character is same 
          # as previous one, increment its count 
          if s[i] == s[i-1]: 
              count += 1
          else: 
              # Append the count and character 
              output += str(count) + s[i-1] 
            
              # Reset the count  
              count = 1
            
      # Append the last obtained character and its count 
      output += str(count) + s[-1]
    
      return output
  
  assert compress("aabbbbbbcccc") == "2a6b4c"
  assert compress("ab") == "1a1b"
  assert compress("aaabbaaccc") == "3a2b2a3c"
  assert compress("a") == "1a"
  assert compress("") == ""
output: def compress(s): 
      if not s:
          return ""
      
      output = "" 
      count = 1
    
      for i in range(1, len(s)): 
          if s[i] == s[i-1]: 
              count += 1
          else: 
              output += str(count) + s[i-1] 
              count = 1
            
      output += str(count) + s[-1]
    
      return output