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")
Python

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

Making GUI Calculator in Tkinter Python

Unlocking Web Design: A Guide to Mastering CSS Layout Modes