520. Detect Capital

xiaoxiao2021-02-27  1.1K+

class Solution(object): def detectCapitalUse(self, word): """ :type word: str :rtype: bool """ word_temp = word[1:]; if (word.lower() == word): return True; if (word.upper() == word): return True; if (len(word)>1 and (word_temp.lower() == word_temp) and (word[0].upper() == word[0])): return True; else: return False; def detectCapitalUse(self, word): return word.isupper() or word.islower() or word.istitle();
转载请注明原文地址: https://www.6miu.com/read-38.html

最新回复(0)