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”.
string=input("Enter string: ")
counter=0
for s in string:
if s!="0" and s!="1":
counter+=1
if counter==0:
print("Binary Number")
else:
print("Not a Binary Number")
Comments
Leave a comment