Function in Python that counts the number of times a character is repeated in a given string

    

    def countxo(string):
    x_count = f"{string}".count("x")
    o_count = f"{string}".count("o")
    if x_count == o_count:
        print(f"Number of x={x_count} and Number of o={o_count}. Hence", True)
    else:
        print(f"Number of x={x_count} and Number of o={o_count}. Hence", False)
        
countxo("xoxox")

    

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

What is the difference between iostream and iostream.h in cpp?

The Basic Structure of a Full-Stack Web App