#Given a string, return its encoding defined as follows:

#First, the string is divided into the least possible number of disjoint substrings consisting of identical characters
#for example, "aabbbc" is divided into ["aa", "bbb", "c"]
#Next, each substring with length greater than one is replaced with a concatenation of its length and the repeating character
#for example, substring "bbb" is replaced by "3b"
#Finally, all the new strings are concatenated together in the same order and a new string is returned.
#Example

#For s = "aabbbc", the output should be
#lineEncoding(s) = "2a3bc".

def lineEncoding(s):

	lista = list(s)
	long = len(lista)

	count = 1
	output = ''
	for i in range(long-1):
		if lista[i] != lista[i+1]:
			if count != 1:
				output += str(count) + lista[i]
			else:
				output += lista[i]
			if i == long-2:
				output += lista[i+1]
			count = 1
		else:
			count += 1
			if i == long-2:
				if count != 1:
					output += str(count) + lista[i]
				else:
					output += lista[i]
	return output