One of the functions in my code takes a user inputted number in binary, and another function converts that number to base 10. For some reason my variables are not working right. The function "base2TO10" is not recognizing the user input that is defined as "base2". How can I fix this and let main run all of my functions?
def isBase2():
flag2 = True
while(flag2 == True):
base2 = input("Enter a base 2 number: ")
try:
base2 = int(base2 , 2)
flag1 = False
return True
except ValueError:
flag1 = True
else:
flag1 = True
return base2
**def base2TO10():
b = base2
number = 0
for idx, num in enumerate(b[::-1]):
base2 += int(num)*(2**idx)
return number**
def main():
if printmenu() == "2":
askUserValue()
isBase2()
base2TO10()