I'm writing a solution for a problem on Codewars, which requires me to return the integer value of an array of binary digits, such as [1, 0, 0, 1] --> 9.
However, I'm not sure of the syntax when converting the binary to integer. Below is my code:
def binary_array_to_number(arr):
n = int("".join(map(str, arr))) # Converts the array of digits into an integer
return int(0b + n) # What I'm having problem with
I understand the "+" is wrong, so what is the proper syntax for the last line of code?