okay = [0, 1, 1, 0]
bad = [0, 1, 2, 3]

def validateBit(b):
    return b in (0, 1)

def checkInput(vals):
    return all(validateBit(b) for b in vals)
checkInput(okay)
checkInput(bad)
Validating the value of several variables