Answer to Question #307228 in Python for jamil

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


1
Expert's answer
2022-03-07T10:27:15-0500
s = input()

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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS