The real problem is there:
write a program that takes a string as input and prints “Binary Number” if the string contains only 0s or 1s. Otherwise, print “Not a Binary Number”.
>Solution :
You can iterate every character of the input and verify it is a zero or a one. The all function can be used for this iteration and check.
Also require that the string has at least one character:
def isBinary(string):
return all(ch in "01" for ch in string) and string != ''
Example use:
string = input("Enter a binary number: ")
if isBinary(string):
print("Thank you!")
else:
print("That is not a binary number.")