This is a function that is able to take in a binary number as a string and convert it into a decimal number. For some reason, this function always returns None and I can not understand why this is happening. If anyone could provide me with an explanation it would be much appreciated.
total = 0
power = 0
def binaryToDecimal(binaryString):
global total, power
n = len(binaryString) - 1
if n < 0:
return total
else:
if binaryString[n] == '1':
total += (2 ** power)
power += 1
binaryToDecimal(binaryString[:-1])