2129. Capitalize the Title

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2129

class Solution:
    def capitalizeTitle(self, title: str) -> str:
        words = [w.lower() if len(w) < 3 else w.capitalize() for w in title.split()]
        return " ".join(words)