"""
List comprehension approach
"""

# Prompt the user to input a binary number as a string.
binary_string = input("Please enter the binary representation of a number: ")

# Get the length of the binary string.
l = len(binary_string)

# Use a list comprehension to calculate the decimal value.
# For each digit in the binary string, multiply it by 2 raised to the power of its position
# (starting from the least significant bit, which is at the end of the string).
result = sum([int(binary_string[l - i - 1]) * 2**i for i in range(l)])

# Print the decimal representation of the binary number.
print(f"The decimal representation of your number is {result}")

