def get8bit():
while True:
try:
bNum = int(input('Please enter your 8 bit number'))
except:
print('Please only enter numbers 0 and 1')
return bNum
def valid8bit(x):
validChoices = [00000000,11111111]
while x not in validChoices:
x = int(input('Please only enter an 8 bit number:'))
if x == validChoices:
break
return x
def convertodeci(y):
y = y ** 2
return y
user = get8bit()
thisValid = valid8bit(user)
userTodeci = convertodeci(thisValid)
print(userTodeci)
I am trying to write a function that both validates that the number the user entered is 0 or 1 AND is 8 bits in length. I know I need to keep looping until it is correct but I cannot get it to validate the input correctly. Please show me what I'm doing wrong! I want to learn :)