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
Post a Comment
Write something to CodeWithAbdur!