I want to return a boolean value of True or False depending on whether the string contains only 1 and 0.
The string should consist of 8 1 or 0 and nothing else.
If it contains only 1 or 0, it will return True , and if it does not return False .
def isItBinary(aString): if aString == 1 or 0: return True else: return False
This is what I have so far, but I'm just not sure how to compare it with both numbers, and also see if it has a length of 8 1 and 0.
source share