DEV Community

Discussion on: Check if the chain has the same amount

Collapse
 
pbouillon profile image
Pierre Bouillon

Python to the rescue !

def dev(inp: str) -> bool:
    return inp.lower().count('x') == inp.lower().count('o')

output

>>> dev('xoxo')
True
>>> dev('xaabboccddxeeffo')
True
>>> dev('x')
False
>>> dev('ooooox')
False