def get_digits(n, reverse=False):
    """Returns the digits of n as a list, from the lowest power of 10 to the highest. If `reverse`
    is `True`, returns them in from the highest to the lowest"""

    digits = []

    while n != 0:
        digits.append(n % 10)
        n //= 10

    if reverse:
        digits.reverse()

    return digits