← Back to challenges

Binary to Decimal Converter

PythonHardloopsmath

Instructions

You are given one input: a list containing eight 1's and/or 0's. Write a function that takes an 8 bit binary number and converts it to decimal.

Examples

binary_to_decimal([1, 1, 1, 1, 1, 1, 1, 1]) ➞ 255

binary_to_decimal([0, 0, 0, 0, 0, 0, 0, 0]) ➞ 0

binary_to_decimal([1, 0, 1, 1, 1, 1, 0, 0]) ➞ 188

Notes

Return an integer.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Letters Only