## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# How to do it...

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

1. Create a new file called recipe20.py for the code from this recipe.
1. 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) ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required