1def getBaseTen(binaryVal):
2 count = 0
3
4 #reverse the string
5 binaryVal = binaryVal[::-1]
6
7 #go through the list and get the value of all 1's
8 for i in range(0, len(binaryVal)):
9 if(binaryVal[i] == "1"):
10 count += 2**i
11
12 return count
1# Convert integer to binary
2>>> bin(3)
3'0b11'
4
5# Convert binary to integer
6>>> int(0b11)
73