Answer to Question #306379 in Python for ratul

Question #306379

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-05T04:11:48-0500
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")

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