def problem_19_6(n):
    """ Given an integer between 0 and 999,999, print an English phrase that
    describes the integer (eg, “One Thousand, Two Hundred and Thirty Four”).
    """
    words = {
        0:    'Zero',
        1:    'One',
        2:    'Two',
        3:    'Three',
        4:    'Four',
        5:    'Five',
        6:    'Six',
        7:    'Seven',
        8:    'Eight',
        9:    'Nine',
        10:   'Ten',
        11:   'Eleven',
        12:   'Twelve',
        13:   'Thirteen',
        14:   'Fourteen',
        15:   'Fifteen',
        16:   'Sixteen',
        17:   'Seventeen',
        18:   'Eighteen',
        19:   'Nineteen',
        20:   'Twenty',
        30:   'Thirty',
        40:   'Fourty',
        50:   'Fifty',
        60:   'Sixty',
        70:   'Seventy',
        80:   'Eighty',
        90:   'Ninty',
        100:  'Hundred',
        1000: 'Thousand'
    }

    def digits(n):
        if n == 0:
            return ''
        return words[n]

    def tens(n):
        if n < 10:
            return digits(n)
        if n in words:
            return words[n]

        first = n / 10
        return words[first*10] + ' ' + digits(n % 10)

    def hundreds(n):
        if n < 100:
            return tens(n)
        first = n / 100

        if first == 0:
            return tens(n % 100)
        else:
            word = 'Hundred' if first == 1 else 'Hundreds'
            out = words[first] + ' ' + word
            rest = tens(n % 100)
            if rest != '':
                out += ' and ' + rest
            return out

    def thousands(n):
        if n > 999999:
            raise Exception('Input number is too large')
        if n < 1000:
            return hundreds(n)

        word = 'Thousands' if n > 1999 else 'Thousand'
        out = hundreds(n / 1000) + ' ' + word

        rest = hundreds(n % 1000)
        if rest != '':
            out += ', ' + rest
        return out


    return thousands(n)