def digits_to_num(L, reverse=False):
    """Returns a number from a list of digits, given by the lowest power of 10 to the highest, or
    the other way around if `reverse` is True"""

    digits = reversed(L) if reverse else L
    n = 0

    for i, d in enumerate(digits):
        n += d * (10 ** i)

    return n