x

This will print the count immediately after the input line. The following should be used:
    result = ''
    for i in range(0, t):
        input_str = input()
        result += str(stringReduction(input_str)) + '\n'

    print(result.rstrip('\n'))