Number 520

https://leetcode.com/problems/detect-capital

[11]:
class Solution:
    def detectCapitalUse(self, word: str) -> bool:
        if all([ord(x) >= 65 and ord(x) <= ord('Z') for x in word]):
            return True
        if ord(word[0]) >= 65 and ord(word[0]) <= ord('Z') and all([ord(x) < 65 or ord(x) > ord('Z') for x in word[1:]]):
            return True
        if all([ord(x) < 65 or ord(x) > ord('Z') for x in word]) :
            return True
        return False
[16]:
a = Solution()
print(a.detectCapitalUse('g'))
print(a.detectCapitalUse('Leetcode'))
print(a.detectCapitalUse('FlaG'))
True
True
False

While this is fairly plebian a problem on the face of it, where it distinguishes itself in its demand that “capital” means that either no letter be capitalized or all of them be capitalized in addition to the normal meaning of what a capitalized word means.