Question #307228

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”.


Expert's answer

s = input()

for ch in s:
    if ch != '1' and ch != '0':
        print('Not a Binary Number')
        break
else:
    print('Binary Number')
LATEST TUTORIALS
APPROVED BY CLIENTS