With the following steps, we will experiment with filtering out test results and easing certain restrictions of `doctest`:

- Create a new file called
`recipe20.py`for the code from this recipe.

- Create a recursive function that converts base-10 numbers into other bases:

def convert_to_basen(value, base): import math def _convert(remaining_value, base, exp): def stringify(value): if value > 9: return chr(value + ord('a')-10) else: return str(value) if remaining_value >= 0 and exp >= 0: factor = int(math.pow(base, exp)) if factor <= remaining_value: multiple = remaining_value / factor return stringify(multiple) + \ _convert(remaining_value-multiple*factor, \ base, exp-1) else: return "0" + \ _convert(remaining_value, base, exp-1) ...