Binary String

    0

    0

    Aakanksha Priya

    Check whether the given string is binary or not

    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)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.