detect-capital.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:lc-all-solutions 作者: csujedihy 项目源码 文件源码
def detectCapitalUse(self, word):
        """
        :type word: str
        :rtype: bool
        """
        ud = set(string.uppercase)
        ld = set(string.lowercase)
        n = len(word)
        cap = 0
        for c in word:
            if c in ud:
                cap += 1
        if cap == n:
            return True
        if cap == 1 and word[0] in ud:
            return True
        return False if cap > 0 else True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号