美文网首页
Exes and Ohs

Exes and Ohs

作者: 是不及呀 | 来源:发表于2018-11-28 11:03 被阅读0次
* *
链接 Exes and Ohs
难度 7kyu
状态
日期 2018-11-25

题意

题解1

def xo(s):
    a = 0
    b = 0
    for i in s:
        if i == 'x' or i == 'X':
            a += 1
    for j in s:
        if j == 'o' or j == 'O':
            b += 1
    if a ==b:
        return True
    else:
        return False

题解2

def xo(s):
    a = 0
    b = 0
    for c in s:
        if c == 'x' or c == 'X':
            a += 1
        if c == 'o' or c == 'O':
            b += 1
    if a == b:
        return True
    else:
        return False

题解3

def xo(s):
    a = 0
    b = 0
    for c in s:
        if c == 'x' or c == 'X':
            a += 1
        if c == 'o' or c == 'O':
            b += 1
    return a == b

相关文章

网友评论

      本文标题:Exes and Ohs

      本文链接:https://www.haomeiwen.com/subject/eajoqqtx.html