Given a word, you need to judge whether the usage of capitals in it is right or not.



We define the usage of capitals in a word to be right when one of the following cases holds:

All letters in this word are capitals, like "USA".
All letters in this word are not capitals, like "leetcode".
Only the first letter in this word is capital if it has more than one letter, like "Google".

Otherwise, we define that this word doesn't use capitals in a right way.



Example 1:

Input: "USA"
Output: True



Example 2:

Input: "FlaG"
Output: False



Note:
The input will be a non-empty word consisting of uppercase and lowercase latin letters.

Difficulty: EASY
Starter code: class Solution:
    def detectCapitalUse(self, word: str) -> bool:
        

Solutions:
class Solution:

	def detectCapitalUse(self, word):
		if len(word) == 0:
			return True
		elif word.isupper() or word.islower():
			return True
		elif len(word) > 1:
			return word.istitle()
		else:
			return False


class Solution:

	def detectCapitalUse(self, word):
		if word.isupper():
			return True
		if word.islower():
			return True
		if word[0].isupper() and word[1:].islower():
			return True
		return False


class Solution:

	def detectCapitalUse(self, word):
		for (i, w) in enumerate(word):
			is_cap = ord(w) < ord('a')
			if i == 0:
				if is_cap:
					first_cap = True
					keep_cap = False
				else:
					first_cap = False
					keep_cap = False
			else:
				if not first_cap and is_cap:
					return False
				if keep_cap and (not is_cap):
					return False
				if not keep_cap and i > 1 and is_cap:
					return False
				if i == 1 and is_cap and first_cap:
					keep_cap = True
		return True


class Solution:

	def detectCapitalUse(self, word):
		return word[1:] == word[1:].lower() or word == word.upper()


class Solution:

	def detectCapitalUse(self, word):
		return word.islower() or word.isupper() or word.istitle()


class Solution:

	def detectCapitalUse(self, word):
		return word[1:].islower() or word.isupper() or word.islower()