# Compress string using counts of repeated characters

def compress_str(str):
	output = ""
	curr_char = ""
	char_count = ""

	for i in str:

		if curr_char != str[i]:
			output = output + curr_char + char_count # add new unique character and its count to our output
			curr_char = str[i] # move on to the next character in string
			char_count = 1 # reset count to 1
		else: # add to repeated count if there is a match
			char_count += 1

# Compress string using counts of repeated characters

def compress_str(string):
	output = ""
	char_count = 1

	# add first character
	output += string[0]

	for i in range(len(string)-1): # doesn't do character count for last group of a unique character
		if string[i] == string[i+1]:
			char_count += 1
		else:
			output += str(char_count) + string[i+1] # add count and next unique character
			char_count = 1 # reset character count

	# account for count of last character
	output += str(char_count)

	print output


# test cases
compress_str("ssssssss") # prints "s8"
compress_str("abbcccdddd") # prints "a1b2c3d4"

Rewrite method and add test cases
Rewrite method and add test cases
