DEV Community

Discussion on: Daily Challenge #29 - Xs and Os

Collapse
 
hectorpascual profile image

Python goes there :

def XO(input):
    x_count = 0
    o_count = 0
    for c in input:
        if c.lower() == 'x':
            x_count += 1
        elif c.lower() == 'o':
            o_count += 1
    return bool(x_count == o_count)

[V2] - One liner :

XO = lambda input : bool(input.lower().count('x') == input.lower().count('o'))