input: Write a function to compress a given string by replacing all repeating characters with a single instance and its count. If there are no repeating characters, the original string should be returned unchanged.
  assert compress("aabbbbbbcccc")== "a2b6c4"
  assert compress("abcdef")== "abcdef"
  assert compress("aaabbaa")== "a3b2a2"
  assert compress("")== ""
  assert compress("a")== "a"
  assert compress("aaa")== "a3"
output: def compress(s):
      if not s:
          return s
      compressed = []
      count = 1
      for i in range(1, len(s)):
          if s[i] == s[i-1]:
              count += 1
          else:
              compressed.append(s[i-1] + (str(count) if count > 1 else ''))
              count = 1
      compressed.append(s[-1] + (str(count) if count > 1 else ''))
      return ''.join(compressed)