Ask Your Question

Revision history [back]

The following function converts integers in any base to any other base:

def base_conversion(number, base_from, base_to):
    if(base_from==10):
        return (number.str(base=base_to))
    else:
        decimal = Integer(str(number), base=base_from)
        return (decimal.str(base=base_to))