1
2
3
4
5
6
7
8
9
10
11
12
13
|
class Solution:
def capitalizeTitle(self, title: str) -> str:
titleList=list(title.split())
ans=''
for i in titleList :
i = i.lower()
if len(i)<3: ans+=i
else:
for j in range(len(i)):
if j==0 : ans+=i[j].upper()
else: ans+=i[j]
ans+=' '
return ans[:-1]
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 448. Find All Numbers Disappeared in an Array (0) | 2022.03.28 |
---|---|
Leetcode 268. Missing Number (0) | 2022.03.28 |
leetcode 217. Contains Duplicate (0) | 2022.03.24 |
leetcode 389. Find the Difference (0) | 2022.03.24 |
leetcode 1394. Find Lucky Integer in an Array (0) | 2022.03.24 |
댓글