• Strange error output.

 

I would like to give some feedback about output from Checkio assertions.
It says:
Your result: 'one hundred'
Right result: 'one hundred'
I have no idea what's wrong.

My code:

FIRST_TEN = ["one", "two", "three", "four", "five", "six", "seven",
             "eight", "nine"]
SECOND_TEN = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
              "sixteen", "seventeen", "eighteen", "nineteen"]
OTHER_TENS = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy",
              "eighty", "ninety"]
HUNDRED = "hundred"


def checkio(number):
    repr = {"0": "", "00": "", "000": ""}
    for i in range(1, 10):
        repr[str(i)] = FIRST_TEN[i-1]
    for i in range(10, 20):
        repr[str(i)] = SECOND_TEN[i-10]
    for i in range(20, 91, 10):
        repr[str(i)] = OTHER_TENS[i // 10 - 2]

    num = str(number)[::-1]
    string = ""

    skip = 0
    for i, x in enumerate(num):
        if skip > 0:
            skip -= 1
            continue

        if len(num) > i+2:
            string += repr[num[i+2]] + " " + HUNDRED + " " + checkio(num[i+1] + x)
            skip = 2

        elif len(num) > i+1:
            if num[i+1] == "1":
                string += repr[num[i+1] + x]
            else:
                m = repr[num[i+1] + "0"] + " " + repr[x]

                if len(m) > 0 and m[0] == " ":
                    m = m[1:]
                if len(m) > 0 and m[-1] == " ":
                    m = m[:-1]

                string += m
            skip = 1

        else:
            string += repr[x]

    return string

if __name__ == '__main__':
    #These "asserts" using only for self-checking and not necessary for auto-testing
    assert checkio(4) == 'four', "1st example"
    assert checkio(133) == 'one hundred thirty three', "2nd example"
    assert checkio(12) == 'twelve', "3rd example"
    assert checkio(101) == 'one hundred one', "4th example"
    assert checkio(212) == 'two hundred twelve', "5th example"
    assert checkio(40) == 'forty', "6th example"
    assert not checkio(212).endswith(' '), "Don't forget strip whitespaces at the end of string"

From: http://www.checkio.org/mission/speechmodule/solve/

HTTP_USER_AGENT:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36
9