as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
write a function to revert a given number to its base 10 form from its binary form.
user
def binary_to_decimal(binary):
    # initialize value to 0, which will be the output
    value = 0

    # iterate through each binary digit, starting from the least significant bit
    for i in range(len(binary)-1, -1, -1):
        # if the binary digit is 1, add 2^i to the value, where i is the index of the binary digit
        if binary[i] == '1':
            value += 2**(len(binary)-i-1)

    return value
assistant