版权声明:本文为博主原创文章,请尊重原创,转载请注明原文地址和作者信息! https://blog.csdn.net/zzc15806/article/details/82496993
class Solution:
def detectCapitalUse(self, word):
"""
:type word: str
:rtype: bool
"""
if 'A'<=word[0]<='Z':
return word[1:].lower() == word[1:] or word[1:].upper() == word[1:]
else:
return word.lower() == word
class Solution:
def detectCapitalUse(self, word):
"""
:type word: str
:rtype: bool
"""
count = 0
for c in word:
if c.isupper():
count += 1
return count == 0 or count == len(word) or (count == 1 and word[0].isupper())