Can someone solve this practice exam question, python 3

def bin2dec(s):
product = 1
decimal = 0
for x in s[::-1]:
if (x=='1'):
decimal += product
product = product * 2
return decimal
# Testing
print(bin2dec('110'))
print(bin2dec('11111111'))
print(bin2dec('1'))

Can someone solve this practice exam question, python 3 5. (+15) Write a function bin 2dec...
please answer in python
print Cannot divide anything but numbers. else - print n. 5. (+15) Write a function bin2dec( ) that takes a string representation of any length binary number and returns the decimal equivalent without using any type_conversions. Remember that the binary representation of a number has a power of 2 in each position, starting with 2° in the right most position and increasing by 1 as it moves left (e.g. 242'2') 6 >>> binadec('110') 2721862.1 >>> bin2ded('11111111)...