Given a word, check whether the usage for capital letter is correct. The rules are:
- Capital letter should be the first one if there is only one.
- If there are more than one capital letters, then the whole word should be in uppercase.
- It’s ok to have all lowercase letters.
Sample Input:
CodeGuru
Sample Output:
False
With the sample input, the second capital letter G is invalid.
数据结构和算法:初级练习题 #43 – 大写字母
给定一个单词,检查其中的大写字母是否符合要求。这里的规则是:
- 如果只有一个大写字母,那么它必须是第一个。
- 如果不止一个大写字母,那么所有的字母都必须是大写字母。
- 如果没有大写字母也是可以的。
输入样例:
CodeGuru
输出样例:
False
输入样例中的大写字母G不符合要求。