Question: Need solution to this python question. Binary to decimal. Write a program that prompts the user for a binary number with the length from 1

Need solution to this python question. Binary to decimal.
Write a program that prompts the user for a binary number with the length from 1 to 20 digits then output its corresponding decimal value. Your program will output Error if the length of the binary number is not valid. *Assumption: Input will always be in the form of binary numbers, you just need to ensure length of digits is valid. + The algorithm to convert the number from binary to decimal is 1st digit * 2 + 2nd digit * 21 + 3rd digit * 22 + 4th digit * 23 + ... + nth digit * 2 (n-1) Example if a binary number is 1100 The decimal value is calculated via 0* 2 + 0* 21 + 1* 22 + 1 * 23 = 0 * 1 + 0* 2 + 1 * 4+1*8 = 12 Sample Run 1: Enter your binary number:111001 57 Sample Run 2: Enter your binary number:1111111111000000110101 Error
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
