Detect Capital
Return True if the capital letters in word are used correctly, which means exactly one of these holds:
- Every letter is a capital.
- No letter is a capital.
- Only the first letter is a capital.
Otherwise return False.
Example 1
word "USA"
returns true
All capitals, so True.
Example 2
word "FlaG"
returns false
A capital in the middle, so False.
Constraints
1 <= len(word) <= 100wordhas only English letters
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.