-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path520. Detect Capital.py
More file actions
38 lines (32 loc) · 875 Bytes
/
Copy path520. Detect Capital.py
File metadata and controls
38 lines (32 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Solution(object):
def detectCapitalUse(self, word):
"""
:type word: str
:rtype: bool
"""
match1,match2,match3 = True,True,True
len_word = len(word)
if len_word < 1 or len_word > 100:
return False
count = 0
if word[0].isupper():
for l in range(1,len_word):
if not word[l].islower():
match1 = False
break
if match1:
return True
count = 0
for l in word:
if l.isupper():
match2 = False
break
if match2:
return True
count = 0
for l in word:
if l.islower():
match3 = False
break
if match3:
return True