Python one line solution

  • 0

    Using Python built-in string method str.islower() and str.isupper()

    class Solution(object):
        def detectCapitalUse(self, word):
            :type word: str
            :rtype: bool
            return (word[1:].islower() or len(word) == 1) if word[0].islower() else (word[1:].islower() or word[1:].isupper() or len(word) == 1)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.