def bincheck(string) :
          t = '01'
          #set counter to 0
          count = 0
          # looping through each character
          # of the string .
          for char in string :
              if char not in t :
                  count = 1
                  break
              else :
                  pass
          if count :
              print("No, the string is not binary.")
          else :
              print("Yes, the string is binary.")
      string = input("Enter string: ")
      # function calling
      bincheck(string)
      
      Python language logo

      Binary String

      Check whether the given string is binary or not

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.