관리 메뉴

솜씨좋은장씨

[leetCode] 2129. Capitalize the Title (Python) 본문

Programming/코딩 1일 1문제

[leetCode] 2129. Capitalize the Title (Python)

솜씨좋은장씨 2022. 1. 24. 00:22
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 leetCode의 Capitalize the Title 입니다.

 

Capitalize the Title - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

👨🏻‍💻 코드 ( Solution )

class Solution:
    def capitalizeTitle(self, title: str) -> str:
        answer = []
        lower_title = title.lower()
        
        lower_title_list = lower_title.split()
        
        for title in lower_title_list:
            if len(title) > 2:
                title = title.capitalize()
            
            answer.append(title)
                
        return " ".join(answer)

 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments