"""
Iterative approach
"""

# Prompt the user to input a binary number as a string.
binary_string = input("Please enter the binary representation of a number: ")

# Initialize the result to 0.
result = 0

# Get the length of the binary string.
l = len(binary_string)

# Loop through each digit in the binary string.
# For each digit, compute its positional value (2**i) and add it to the result.
for i in range(l):
    result += int(binary_string[l - i - 1]) * 2**i

# Print the decimal representation of the binary number.
print(f"The decimal representation of your number is {result}")

