I'm trying to get toBase10(101)
to spit out 5
. I also need it to work for numbers besides 101, I know that there is a binary converter built into python but I can't figure it out.
Right now I have
def toBase10(x):
int( 'x' , 2 ) == x
return x
I get the error can't convert non-string with explicit base. Why can't I use x in here?