input: Write a function to compress a given string by replacing all repeating characters with a single instance and its count. The function should iterate through the string, count consecutive repeating characters, and then compress these characters into a new string where each character is followed by its count. If the given string is empty, return an empty string.
  
  def compress(s):
      if not s:
          return ""
      
      output = ""
      count = 1
      
      for i in range(len(s) - 1):
          if s[i] == s[i + 1]:
              count += 1
          else:
              output += s[i] + str(count)
              count = 1
      
      output += s[-1] + str(count)
      return output
  
  assert compress("aabbbbbbcccc") == "a2b6c4"
  assert compress("aaabbbccc") == "a3b3c3"
  assert compress("abc") == "a1b1c1"
  assert compress("") == ""
  assert compress("a") == "a1"
output: def compress(s):
      if not s:
          return ""
      
      output = ""
      count = 1
      
      for i in range(len(s) - 1):
          if s[i] == s[i + 1]:
              count += 1
          else:
              output += s[i] + str(count)
              count = 1
      
      output += s[-1] + str(count)
      return output